Skip to content

Never/NoReturn narrowing #361

@Zaczero

Description

@Zaczero

Describe the Bug

from typing import *

def raise_error() -> NoReturn:
    raise Exception()

a = cast(int | None, 1)
if a is None:
    raise_error()

reveal_type(a)  # revealed type: int | None

I expect a to be narrowed to int.

Sandbox Link

https://pyrefly.org/sandbox/?code=GYJw9gtgBALgngBwJYDsDmUkQWEMoBUAUEQCYCmwUIAhkgM7kD65I4IAFAJRQC0AfFAByYAErkYAVxAoAXESiLqdRlACiADwDG5BDCRgU3EjSgBeKFpr0YHVPgA+ww+QA0UAIxciSKqYbOKOTySsoMzKzsxkQg5ABu5DQANkzwCOQcNFxAA

(Only applicable for extension issues) IDE Information

No response

Metadata

Metadata

Assignees

Labels

Type

No fields configured for Bug.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions