seq-lang / seq

A high-performance, Pythonic language for bioinformatics

Home Page:https://seq-lang.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] bool type cannot be used as dict key

jalfje opened this issue · comments

(Seq 0.9.10)

This is not so useful except when the bool is part of a tuple, e.g. d = dict[tuple[int, bool], int](). Minimum working example:

d = dict[tuple[int, bool], int]()
d[(0, True)] = 1

Gives the error:

builtin.seq:116:12: error: cannot find method '__hash__' for type 'bool' with specified argument types ()

Currently a workaround is probably to extend the bool type, but it would be nice for that to be built-in.

Thanks for pointing this out; we'll definitely add it in the next release!

A workaround in the meantime is extend as you mentioned:

extend bool:
    def __hash__(self: bool):
        return int(self)