pyrefly icon indicating copy to clipboard operation
pyrefly copied to clipboard

Constrained typevar cannot be attribute-accessed

Open grievejia opened this issue 9 months ago • 1 comments

Describe the Bug

Minimal repro:

class A:
    x: int

class B:
    x: int

class Foo[T: (A, B)]:
    y: T
    def foo(self) -> None:
        self.y.__class__

Expected: No error Actual: TODO: Expr::attr_infer_for_type attribute base undefined for type: TypeVar[T] (trying to access class)

Sandbox Link

https://pyrefly.org/sandbox/?code=MYGwhgzhAECCBcAoaLoA97QJYDsAuiiokMAQkquprgUeFNAGID2zA2gCqYAUsANNFIBKALoVUAT0wdkqACYBTAGbQlrbhAUglQ6AFoAfNAByzHAvGUUm7QDoJtgPqPiUZ4iA

(Only applicable for extension issues) IDE Information

No response

grievejia avatar May 20 '25 19:05 grievejia

similar to the first issue from https://github.com/facebook/pyrefly/issues/150

yangdanny97 avatar May 20 '25 22:05 yangdanny97