Skip to content

What would it take to make unhashable dict key a static error? #40

Description

@LuKuangChen

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions