"cannot get type" with TypeVar field #223

Closed
opened 2022-03-18 11:34:50 +08:00 by sb10q · 1 comment
@extern
def output_int32(x: int32):
    ...

class A:
    def __init__(self):
        pass

    def foo(self):
        output_int32(1)

class B:
    def __init__(self):
        pass

    def foo(self):
        output_int32(2)


T = TypeVar("T", A, B)


class C(Generic[T]):
    x: T

    def __init__(self, x: T):
        self.x = x

    def foo(self):
        x.foo()


def run() -> int32:
    insta = A()
    inst = C(insta)
    inst.foo()
    return 0
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: "type error at identifier `x` (cannot get type of x) at src/classes.py: line 30 column 9"', nac3standalone/src/main.rs:223:35
```python @extern def output_int32(x: int32): ... class A: def __init__(self): pass def foo(self): output_int32(1) class B: def __init__(self): pass def foo(self): output_int32(2) T = TypeVar("T", A, B) class C(Generic[T]): x: T def __init__(self, x: T): self.x = x def foo(self): x.foo() def run() -> int32: insta = A() inst = C(insta) inst.foo() return 0 ``` ``` thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: "type error at identifier `x` (cannot get type of x) at src/classes.py: line 30 column 9"', nac3standalone/src/main.rs:223:35 ```
Poster
Owner

PEBKAC

PEBKAC
sb10q closed this issue 2022-03-18 16:31:56 +08:00
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: M-Labs/nac3#223
There is no content yet.