Skip to content

Weird matching on sets #101878

Description

@isaacl

Bug report

While attempting to use match to extract an element from a singleton set, I stumbled across a weird matching pattern:

s = set('A')
match s:
    case set(x):
        print(x is s)  # Prints True

For some reason, the x variable gets assigned to the collection itself, instead of the contents. Is this intended?

cpython 3.11.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions