Summary
The int type can store arbitrary precision values (backed by big.Int), but arithmetic operations incorrectly check against int64 bounds and fail with overflow errors.
Steps to Reproduce
Storage works (arbitrary precision):
import @std
using std
do main() {
temp big int = 999999999999999999999999999999999999999999999999999999999999
println("Big: ${big}") // Works!
}
Arithmetic fails (int64 cap):
import @std
using std
do main() {
temp a int = 999999999999999999999999999999
temp b int = a + a // ERROR: exceeds int64 range
}
error[E5005]: integer overflow: 999999999999999999999999999999 + 999999999999999999999999999999 exceeds int64 range
Even simple operations fail:
temp x int = 999999999999999999999999999999 + 1 // ERROR
Expected Behavior
Since int uses big.Int internally, all arithmetic operations should also use arbitrary precision:
temp a int = 999999999999999999999999999999
temp b int = a + a // Should work: 1999999999999999999999999999998
temp c int = a * a // Should work: massive number
Affected Operations
- Addition (
+)
- Multiplication (
*)
- Likely subtraction and others too
Root Cause
The evaluator is likely converting big.Int to int64 before performing arithmetic operations, then checking for overflow. The fix should use big.Int methods directly (Add, Mul, etc.) without int64 conversion.
Summary
The
inttype can store arbitrary precision values (backed bybig.Int), but arithmetic operations incorrectly check against int64 bounds and fail with overflow errors.Steps to Reproduce
Storage works (arbitrary precision):
Arithmetic fails (int64 cap):
Even simple operations fail:
Expected Behavior
Since
intusesbig.Intinternally, all arithmetic operations should also use arbitrary precision:Affected Operations
+)*)Root Cause
The evaluator is likely converting
big.Inttoint64before performing arithmetic operations, then checking for overflow. The fix should usebig.Intmethods directly (Add,Mul, etc.) without int64 conversion.