Confusing error using primitive as Dict key
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 30/100
Research direction
Reproduce the supplied Python snippet using static and inspect the CheckedDict[int64, bool] getitem path that produces the reported TypeError. Confirm whether primitive keys are supported and establish the expected behavior and diagnostic before changing the runtime handling.
Written by the indexing model from the issue text.
Description
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?!
- Dominant language
- Python
- Stars
- 3.8k
- Forks
- 139
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from facebookincubator/MetaPython
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
facebookincubator/MetaPython#147 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
facebookincubator/MetaPython#146 · 2 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
facebookincubator/MetaPython#145 · 4 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 20/100
facebookincubator/MetaPython#129 · 2 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
facebookincubator/MetaPython#116 · 2 comments ·
All issues in facebookincubator/MetaPython
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
learningequality/ricecooker#747 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
BSData/horus-heresy-3rd-edition#3171 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
run-llama/llama_index#23199 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
KhronosGroup/glTF-Blender-IO#2769 ·