Closed LuKuangChen closed 2 years ago
We noticed that instance fields have a similar issue. The following program passes type check. If the last line is uncommented, a compile-time error will be reported. This shows that the x: str
in the subclass D
is ignored. It might be more sensible to error at the re-declaration, instead of to ignore it silently.
class C:
x: int
class D(C):
x: str
# D().x = "foo" # compile-time type error. int is expected.
Looks like this got fixed with commit 1475ebd1701851cd3e7f6bda6c3b3ce7404953d0
What version of Static Python are you using?
9965302 2021-07-15
What program did you run?
What happened?
The program terminates without errors.
What should have happened?
We expected a compile-time error because
D
override the class variablex
with an incompatible type.