HaxeFoundation / HaxeFoundation/haxe

[hl] Invalid inline - type not replaced for FInstance

Open
#6,071 7 comments 0 reactions 1 assignee Assigned to @Simn View on GitHub
bug feature-inline
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

The following code results in an `Uncaught exception: Access violation Called from hl.types.ArrayDyn.get_length` on HL. Works on all other targets.

```haxe
@:forward
abstract OneOrMany(Array) from Array to Array {
@:from
static function fromSingle(value:T):OneOrMany {
return [value];
}
}

class Test {
inline
public static function firstItem(items:Array):T {
return (items == null || items.length == 0) ? null :items[0];
}

public static function traceFirstString(strings:OneOrMany) {
trace(firstItem(strings)); // access violation is raised here
}

public static function main() {
traceFirstString(["ab", "cd"]);
}
}
```

It works when I remove the `inline` declaration from the `firstItem` method

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.