Skip to content

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

Open

Description

@tapetersen

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.

Activity

  1. MelbourneDeveloper commented on Aug 3, 2026

    @MelbourneDeveloper
    Collaborator

    Refs #374 — confirmed live, now permanently measured.

    This exact reproducer is now a case in the new type-torture scoreboard (benchmarks/torture/cases/enum_literal_expansion.py, runner benchmarks/torture/run_torture.py on bidirectionaltype-inference). Today's measured run confirms the false positive against a release binary built from HEAD:

    error[assignment_compatibility]: Type mismatch: `x` is annotated `Literal[Answer.Yes, Answer.No]` (answer.yes | answer.no) but assigned answer
      --> enum_literal_expansion.py:20:5
    

    Scoreboard context (out-of-the-box defaults, methodology in the runner header): mypy, ty, and pyrefly pass the case; basilisk (1 FP), pyright (3 FPs), and zuban (2 FPs) fail it — consistent with the pyright-first history noted here. The case scores both directions of the enum-literal-expansion equivalence plus both assert_type forms, so a partial fix stays visible. Once fixed, the scoreboard's regression gate holds it fixed.

    Not fixed yet — assignment_compatibility (and the assert_type path) still need the complete-union-of-members ≡ enum equivalence.

  2. added a commit that references this issue on Aug 5, 2026
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions