Skip to content

Field values must be hashable #49

@dahlia

Description

@dahlia

Fields of record or union tag must accept only hashable values. For example, a Python code generated from the following IDL:

record test ({bigint} a);

currently can take values that aren't hashable e.g.:

>>> v = Test(a=frozenset([1, 2, 3]))
>>> hash(v)
-3553164928370265785
>>> v2 = Test(a={1, 2, 3})
>>> hash(v2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/.../test/__init__.py", line 56, in __hash__
    return hash((self.a,))
TypeError: unhashable type: 'set'

Expected behavior would be e.g.:

>>> v = Test(a=frozenset([1, 2, 3]))
>>> hash(v)
-3553164928370265785
>>> v2 = Test(a={1, 2, 3})
Traceback (most recent call last):
  ...
TypeError: a must be hashable

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions