HaxeFoundation / HaxeFoundation/haxe
Behavior of UInt8Array.fromArray(x) - where x evaluates to [null]
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
Not sure if this could be labeled as undefined behavior, or can be classified as a bug.
Posting so you can take a look at it.
Code:
```haxe
var intArray = ''.split(' ').map(function(part):Int {
return Std.parseInt(part);
});
trace("intArray: " + intArray);
var u8Array = UInt8Array.fromArray(intArray);
trace("u8Hex: <" + u8Array.view.buffer.toHex() + ">");
```
Output:
| target | intArray | u8Hex |
|--------|----------|-----------|
| js | [null] | <00> |
| python | [null] | Exception |
| eval | [null] | Exception |
| cs | [0] | <00> |
| cpp | [0] | <00> |
| hl | [0] | <00> |
| swf | [0] | <00> |
Now, I'd lean towards how python and eval behave here - throwing an exception at runtime - although they diverge from js!
But there's still the problem that the behavior is inconsistent across targets.
Compiled with 4.0.0-preview.5
Contributor guide
Assessment
This issue has not been assessed yet.