Skip to content

Exhaustive tuple match reports a missing return #5621

Closed as duplicate
Closed as duplicate

Description

@zshuzh

Describe the Bug

def without_fallback(left: bool, right: bool) -> int:
    match left, right:
        case True, True: return 0
        case True, False: return 1
        case False, True: return 2
        case False, False: return 3


def with_fallback(left: bool, right: bool) -> int:
    match left, right:
        case True, True: return 0
        case True, False: return 1
        case False, True: return 2
        case False, False: return 3
        case remaining:
            assert_never(remaining)

without_fallback gives:

ERROR Function declared to return `int`, but one or more paths are missing an explicit `return` [bad-return]

I'd expect both functions to be accepted, as the four cases cover every combination of the two booleans. The accepted assert_never suggests Pyrefly already knows that no values can reach the final case 🤔

Sandbox Link

Sandbox

(Only applicable for extension issues) IDE Information

No response

Activity

  1. rchen152 commented on Nov 13, 2026

    @rchen152
    Contributor

    Thanks for the report! This looks like it likely has the same cause as #5206, so I'm going to merge them.

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