HaxeFoundation / HaxeFoundation/haxe
Long hexadecimal/binary numbers cannot include underscores
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
In Haxe, numbers can use underscores as a numerical separator to make large numbers easier to read. These are also considered valid for hexadecimal and binary numbers, but only if that does not cause them to exceed the string length of the largest possible hex/binary value.
The issue is that this check does not filter out underscores before parsing:
https://github.com/HaxeFoundation/haxe/blob/35cbcb55becab19b21283f7df21b62409631f4bf/src/core/texpr.ml#L599
```haxe
// Valid
var foo:Int = 1_000_000;
var foo:Int = 0x123456;
var foo:Int = 0x12_3456;
var foo:Int = 0x12345678;
// Compilation error: Invalid hexadecimal integer
var foo:Int = 0x1234_5678;
// Valid
var test:Int = 0b10101010101010101010101010101010;
// Compilation error: Invalid binary integer
var test:Int = 0b10101010_10101010_10101010_10101010;
```
Contributor guide
Assessment
This issue has not been assessed yet.