You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
BigInt (a/d)*d + (a%d) drops the remainder term when operands are for...of bindings #9143
Found while benchmarking BigInt division (#9141); reproduces on pristine main 653e886699, unrelated to that change.
Repro
The division identity (a / d) * d + (a % d) === a evaluates to (a / d) * d — the remainder term vanishes — when a and d are bindings from a for...of over a BigInt array:
for(constaof[123456789012345678901234567890n]){for(constdof[1000000007n]){console.log((a/d)*d+(a%d));// node: a perry: (a/d)*d}}
Correct when the same operands are compile-time constants or plain locals — so this is about how for...of bindings type/lower in a compound BigInt expression, not about the division itself (division and remainder each produce correct values individually).
Silent wrong arithmetic in the shape most real code uses to iterate big-number collections, and the dropped term makes results look plausible rather than obviously broken.
Activity
fix(codegen): guard erased BigInt arithmetic results (PerryTS#9143)
fix(codegen): guard erased BigInt arithmetic results (#9143) (#9162)