HaxeFoundation / HaxeFoundation/haxe
Floats being treated as Ints in interp mode
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
**Code**
```
// Test.hx
class Test {
static function main() {
var arr:Array = [52166, 52013];
trace(arr[0] * arr[1]);
trace((arr[0] : Float) * (arr[1] : Float));
}
}
```
**Command**
`haxe --main Test --interp`
Haxe version: 4.2.5
**Expected output**
```
2713310158
2713310158
```
**Actual output**
```
-1581657138
-1581657138
```
Even when the array values are typed as floats, they still seem to be treated as ints and therefore are running into overflow issues.
Contributor guide
Research direction
Start with the Test.hx reproducer and run `haxe --main Test --interp` using Haxe 4.2.5. Trace the two Float multiplications and compare interpreter behavior with the expected value. Done means both expressions produce 2713310158 without integer overflow.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100