Basilisk fails union-of-members/enum equivalency in some case.

Open
#374 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
python, rust

Research direction

Start with the linked Basilisk playground reproduction and the typing-spec enum-literal-expansion section. Trace the type-checker path for enum types versus complete unions of literal members; done means the sample no longer reports assignment_incompatibility and its assert_type expectation is accepted.

Written by the indexing model from the issue text.

Description

In typing spec at: #enum-literal-expansion.

Likewise, a type checker should treat a complete union of all literal members as equivalent to the enum type:

Code below reports assignment_incompatibility for x

class Answer(enum.Enum):
    Yes = 1
    No = 2

def test4(a: Answer) -> None:
    x: Literal[Answer.Yes, Answer.No] = a
    assert_type(a, Literal[Answer.Yes, Answer.No])

Playground link

This was first reported against pyright but since this was a hole in the conformance suite as well and I opened an issue and PR about it here and discovered basilisk also failed in 1 case.

Dominant language
Rust
Stars
54
Forks
3
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Nimblesite/Basilisk

All issues in Nimblesite/Basilisk

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.