Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incompatible intersections should become Never #432

Open
Tracked by #481
DetachHead opened this issue Mar 29, 2023 · 2 comments · May be fixed by #530
Open
Tracked by #481

incompatible intersections should become Never #432

DetachHead opened this issue Mar 29, 2023 · 2 comments · May be fixed by #530

Comments

@DetachHead
Copy link
Collaborator

DetachHead commented Mar 29, 2023

a: int & str
reveal_type(a)  # int & str, should be Never
@KotlinIsland
Copy link
Owner

KotlinIsland commented Mar 29, 2023

Or maybe an error?

Maybe an error if the resulting type is Never, but sections of a type could just evaporate away.

@KotlinIsland KotlinIsland changed the title non-overlapping intersections should become Never incompatible intersections should become Never Apr 29, 2023
@KotlinIsland
Copy link
Owner

As observed in #469 by @zevbo

from enum import Enum
from typing import Generic, Literal, TypeVar

class E(Enum):
    A = 0 
    B = 1

T = TypeVar("T", Literal[E.A], Literal[E.B])

class A(Generic[T]): 
    pass 

class B(A[Literal[E.A]]): 
    pass 

class C(A[Literal[E.B]]):
    pass 

TheUnion = B | C

def a(b: A[E.A] & TheUnion) -> B:
    return b  # Incompatible return value type (got "A[E.A] & B | C", expected "B")  [return-value]

@KotlinIsland KotlinIsland linked a pull request Oct 9, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants