[red-knot] binary arithmetic on instances (#13800)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
Carl Meyer
2024-10-19 08:22:54 -07:00
committed by GitHub
parent 36cb1199cc
commit f4b5e70fae
5 changed files with 656 additions and 41 deletions

View File

@@ -34,19 +34,19 @@ reveal_type(b) # revealed: int
c = 3 % 0 # error: "Cannot reduce object of type `Literal[3]` modulo zero"
reveal_type(c) # revealed: int
d = int() / 0 # error: "Cannot divide object of type `int` by zero"
# TODO should be int
reveal_type(d) # revealed: @Todo
# error: "Cannot divide object of type `int` by zero"
# revealed: float
reveal_type(int() / 0)
e = 1.0 / 0 # error: "Cannot divide object of type `float` by zero"
# TODO should be float
reveal_type(e) # revealed: @Todo
# error: "Cannot divide object of type `float` by zero"
# revealed: float
reveal_type(1.0 / 0)
class MyInt(int): ...
# No error for a subclass of int
# TODO should be float
reveal_type(MyInt(3) / 0) # revealed: @Todo
# revealed: float
reveal_type(MyInt(3) / 0)
```