HaxeFoundation / HaxeFoundation/haxe
Abstract typing discrepancy
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
When typing the following code:
```haxe
abstract ArrayWrap(std.Array) from std.Array to std.Array
{
inline public function new()
{
this = [];
}
}
class Main
{
static function main()
{
var array:ArrayWrap = [];
trace(array[0].length);
}
}
````
We get:
```
[Field:Unknown<2>]
[Array:{ length : Unknown<2> }]
[Local array(3772):ArrayWrap:ArrayWrap]
[Const:Int] 0
[FAnon:Unknown<2>] length
```
Replacing `ArrayWrap` by `Array` instead produces (more correct):
```
[Field:Dynamic]
[Array:Dynamic]
[Local array(3772):Array:Array]
[Const:Int] 0
[FDynamic:Dynamic] length
```
This causes HL to compile invalid bytecode in the first case.
Related issue: https://github.com/HaxeFoundation/hashlink/issues/201
@Simn if we want to keep a difference in typing, we should at least have a TCast somewhere, I think.
Contributor guide
Assessment
This issue has not been assessed yet.