What would it take to make unhashable dict key a static error?
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
Research direction
Start by running compile_nested_dict_dict_key.py with the reported Static Python revision and inspect how CheckedDict[B, int] is treated as a key. Determine whether the type system can use hash; done means the example produces a compile-time error rather than the runtime TypeError.
Written by the indexing model from the issue text.
Description
What version of Static Python are you using?
9965302
2021-07-15
What program did you run?
# compile_nested_dict_dict_key.py
from __static__ import CheckedDict
class B: pass
class D(B): pass
def testfunc():
x = CheckedDict[B, int]({B():42, D():42})
y = CheckedDict[CheckedDict[B, int], int]({x: 42})
return y
print(testfunc())
What happened?
The program raises a runtime error.
TypeError: unhashable type: 'dict[B, int]'
What should have happened?
We expected a compile-time error complaining that CheckedDict[B, int] is unhashable. Maybe the type system can look for a __hash__ method.
- 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 3/5 1-2 days Newbie friendliness 30/100
facebookincubator/MetaPython#144 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 20/100
facebookincubator/MetaPython#129 · 2 comments ·
All issues in facebookincubator/MetaPython
Similar issues
-
Add: hunch Open
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
AbdelStark/awesome-typesafe#104 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
DiamondLightSource/dodal#2211 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
openml/openml-python#1749 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
sipyourdrink-ltd/bernstein#6191 ·