Skip to content

To add boolean keys in dictionaries. #1710

Closed
@faze-geek

Description

@faze-geek

Since boolean values namely True and False are hashable they can be used as dictionary keys -

def f():
    d: dict[bool,i32]
    d = {True: 1, False: 0}
    print(d)
f()
(lp) C:\Users\kunni\lpython>python try.py
{True: 1, False: 0}

(lp) C:\Users\kunni\lpython>src\bin\lpython try.py
Internal Compiler Error: Unhandled exception
Traceback (most recent call last):
LCompilersException: Hashing bool isn't implemented yet.

I am working on this. @czgdp1807 @certik is there a way / design that should be followed to implement the hashing ? Kindly let me know any reference prs / issues I should follow.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions