Skip to content

Match statement on tuple does not match Python semantics #1166

@marten-de-vries

Description

@marten-de-vries

This simple program returns a different output when compiled with mypyc than when run in vanilla Python:

def main() -> None:
    match ("X", "Y"):
        case ("X", "Y") | ("X", "Z"):
            print("THERE")
        case _:
            print("OTHER")
$ python -c 'import matchtest; matchtest.main()'
THERE
$ mypyc matchtest.py; python -c 'import matchtest; matchtest.main()'
running build_ext
copying build\lib.win-amd64-cpython-312\matchtest.cp312-win_amd64.pyd -> 
OTHER

(Thanks for mypyc, it's a very nice tool!)

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