Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confusing error using primitive as Dict key #144

Open
bennn opened this issue Aug 14, 2024 · 1 comment
Open

Confusing error using primitive as Dict key #144

bennn opened this issue Aug 14, 2024 · 1 comment

Comments

@bennn
Copy link
Contributor

bennn commented Aug 14, 2024

Are primitives like int64 allowed as Dict keys?

I guess not because they can't be sent as function arguments and this program gives a runtime error:

from __static__ import int64, Array, CheckedList, CheckedDict

def create(n: int):
    d = CheckedDict[int64, bool]()
    nn = int64(n)
    if not d[nn]:
      d[nn] = True
    return

create(4)

But the error message is very confusing:

  ....
  File "test.py", line 6, in create
    if not d[nn]:
TypeError: chkdict[int64, bool].__getitem__()() argument 1 expected int64

Argument 1 is an int64 ... right?!

@bennn
Copy link
Contributor Author

bennn commented Oct 22, 2024

Similar error with CheckedList[int64] :

from __static__ import int64, CheckedList

def init():
    empties: CheckedList[int64] = CheckedList[int64]([])
    empties.append(int64(0))

init()
  ...
  File "test.py", line 5, in init
    empties.append(int64(0))
TypeError: chklist[int64].append()() argument 1 expected int64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant