Skip to content

(🐞) false narrowing with reassignment in loop #11612

Description

@KotlinIsland
a: int|Nonea=Noneforiinrange(10):
reveal_type(a) # "None" and also "int | None"ifa:
print(a) # error: unreachablea=i

Also:

a=Noneforbin [1, 2]:
ifaisNone:
a=bcontinueprint("hi") # false unreachable error

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-reachabilityDetecting unreachable codetopic-type-narrowingConditional type narrowing / binder

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions