Expected behavior
A shift count larger than the field bit-width should be rejected with a diagnostic
(there is an unused BitOverFlowInShift error variant for this), not turned into an
unbounded allocation.
The bug
A constant-folded left shift with a large shift count allocates a BigInt whose size is
the shift count in bits, with no upper bound, so the compiler hangs and eventually OOMs.
template T() {
var v = 1 << (1 << 30); // ~1**9-bit intermediate; hangs/OOMs
}
component main = T();
1 << (1 << 30) builds a ~1-billion-bit intermediate; 1 << (1 << 31) and up
OOM-kill the process on a typical CI runner.
Expected behavior
A shift count larger than the field bit-width should be rejected with a diagnostic
(there is an unused
BitOverFlowInShifterror variant for this), not turned into anunbounded allocation.
The bug
A constant-folded left shift with a large shift count allocates a BigInt whose size is
the shift count in bits, with no upper bound, so the compiler hangs and eventually OOMs.
1 << (1 << 30)builds a ~1-billion-bit intermediate;1 << (1 << 31)and upOOM-kill the process on a typical CI runner.