-
Notifications
You must be signed in to change notification settings - Fork 283
Closed
Labels
Description
Describe the Bug
When we assign instance attributes, we need to check for unbound type variables, but the check is incorrectly also flagging type variables which are bound by the right-hand side expression.
from typing import reveal_type
def f[T](x: T) -> T:
return x
class C:
def m[U](self, x: U) -> U:
return x
class D:
def __init__(self, c: C):
self.f = f # Unexpected invalid-type-var
self.g = c.m # Unexpected invalid-type-var
def test(o: D):
reveal_type(o.f) # should be [T](x: T) -> T
reveal_type(o.g) # should be BoundMethod[C, [U](self: C, x: U) -> U]
I believe the error is happening here:
pyrefly/pyrefly/lib/alt/class/class_field.rs
Line 2323 in 6fabfc7
| fn check_and_sanitize_type_parameters( |
We collect the quantified types from the RHS expression, but we only want unbound quantifieds.
Sandbox Link
(Only applicable for extension issues) IDE Information
No response
Reactions are currently unavailable