Closed
Description
Consider the following Python Code:
class Node:
def __init__(self) -> None:
self.wins: int = 0
# self.losses: int = 0
self.parent: None | Node = None
def score1(self) -> int:
n = 0
if self.parent is not None:
n += self.parent.wins
if self.parent is not None:
n += self.parent.losses
return n
@property
def losses(self):
self.wins = 0
self.parent = None
return 0
def score2(self) -> int:
n = 0
if self.parent is not None:
n += self.losses
n += self.parent.wins # no type error !?
return n
n = Node()
m = Node()
n.parent = m
print(n.score2())
It suggests a unsound hole in the type system of Pyright and mypy (both of them suggest no type error as of 2024-10-22) due to dynamic properties performing operations on other properties. Does Racket has similar issues?
Metadata
Metadata
Assignees
Labels
No labels