-
Notifications
You must be signed in to change notification settings - Fork 219
Closed
Labels
bidirectional inferenceInference of types that takes into account the context of a declared type or expected typeInference of types that takes into account the context of a declared type or expected typegenericsBugs or features relating to ty's generics implementationBugs or features relating to ty's generics implementationwishNot on the current roadmap; maybe in the futureNot on the current roadmap; maybe in the future
Description
Summary
def f1() -> list[object]:
return [1, 2, 3] # lovely, bidirectional type inference uses the return type to infer `list[object]`
def f2() -> list[object]:
result = [1, 2, 3]
return result # error: bi-directional type inference does not look ahead, so the inferred type is `list[int]`note that there are two issues preventing the actual error from surfacing:
- return position is not taken into account for constraint solving
[1, 2, 3]is inferred aslist[Unknown | int], which is assignable tolist[object]
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bidirectional inferenceInference of types that takes into account the context of a declared type or expected typeInference of types that takes into account the context of a declared type or expected typegenericsBugs or features relating to ty's generics implementationBugs or features relating to ty's generics implementationwishNot on the current roadmap; maybe in the futureNot on the current roadmap; maybe in the future