Skip to content

Unexpected error when matching over object with a tuple pattern. #1369

Description

@samwgoldman

Describe the Bug

def handle(o: object) -> int:
    match o:
        case ("a", 1): return 1
        case ("b", 1): return 2
        case ("c", 1): return 3
    return 1

Expected: no error
Actual: "object is not iterable" error on each match case

It's possible that other kinds of match patterns have similar behavior, which should also be fixed.

Sandbox Link

https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeSImMYABABYaawAUuiNu2AVjAMYAuAShoBaAHw0I6fogA66GopoBbVP150OchUt29UcGDWayQqUwBoaARkHsATjH4BXewuvzdeg0ZMhsljZ2NI4ubjQATJ5eivqGxqa8gbYOTq4KAMzRiqHpNiAWIM780HAk5IggAMQ0AKolUBD8pDRgzugCELjocPLyVLRguPaq-AD66M7K2DD2zPjsUkKiEnD89tq6ueFgpgByUzMbNMD4AL6m8gUgZI5gUKSE-LjKUBQ1AAqkdw80aFh4fA0XjdSAAc1cai66EI8hqAGUYEY6Px%2BMQ4IgAPSY27UB6EYZgzEwdCYzC4XhwTEg9DgyElbqY1rDGioABuqGgqGwsGBoIgEPsUO6HGIDJ6sPQZH4dG6IjZszg0JoAF4aKYMoRrFEQFczoVUJ0FQAxaAwCj-HAEcogM5AA

(Only applicable for extension issues) IDE Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    narrowingIssues with narrowing - root cause is usually narrowing, flow handling, or bothscoping-control-flowissues related to scoping and control flowtypechecking

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions