Skip to content

Class fields type inference fails in inheritance scenarios in Codon 0.19 #687

@wdx727

Description

@wdx727

In inheritance scenarios, the automatic inference function for class fields in Codon 0.19 fails.

class A:
    def __init__(self, a: int):
        self._a: int = a

class B(A):
    def __init__(self, a: int, b: int):
        super().__init__(a)
        self._b: int = b

    def add(self) -> int:
       return self._a + self._b

print(B(1, 2).add())

An error occurs when the above code is executed. “error: 'A[NoneType]' does not match expected type 'A[int]'”

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions