-
Notifications
You must be signed in to change notification settings - Fork 272
Closed
astral-sh/ruff
#18249Labels
bugSomething isn't workingSomething isn't workingruntime semanticsAccurate modeling of how Python's semantics work at runtimeAccurate modeling of how Python's semantics work at runtime
Description
Summary
from typing import reveal_type
reveal_type(256 % -129)
reveal_type(-129 % 16)
reveal_type(-10 // 8)
reveal_type(10 // -6)Actual results:
3 | reveal_type(256 % -129)
| ^^^^^^^^^^ `Literal[127]`
4 | reveal_type(-129 % 16)
| ^^^^^^^^^ `Literal[-1]`
6 | reveal_type(-10 // 8)
| ^^^^^^^^ `Literal[-1]`
7 | reveal_type(10 // -6)
| ^^^^^^^^ `Literal[-1]`
|
Expected results:
3 | reveal_type(256 % -129)
| ^^^^^^^^^^ `Literal[-2]`
4 | reveal_type(-129 % 16)
| ^^^^^^^^^ `Literal[15]`
6 | reveal_type(-10 // 8)
| ^^^^^^^^ `Literal[-2]`
7 | reveal_type(10 // -6)
| ^^^^^^^^ `Literal[-2]`
|
Pyright had similar bugs:
- Incorrect literal math with modulo operations and negative numbers microsoft/pyright#10167
- Incorrect value inference of
-N // +Nmicrosoft/pyright#10076
Version
ty 0.0.1-alpha.6
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingruntime semanticsAccurate modeling of how Python's semantics work at runtimeAccurate modeling of how Python's semantics work at runtime