HaxeFoundation / HaxeFoundation/haxe

[hl] Cannot extend @:structInit class with constructor in subclass

Open
#10,674 7 comments 0 reactions 1 assignee Claimed by @Simn View on GitHub
feature-structInit
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

On HL, I am not able to extend a `@:structInit` class if the subclass has a constructor, receiving `Invalid_argument("List.map2")`. See below example, which works in try.haxe.org on JS but not HL.

```haxe
package;

class Main {

static public function main():Void {

// Invalid_argument("List.map2")
var b:B = new B();
trace(b.a);
}
}

@:structInit
class A {
public var a:Int;
}

class B extends A {
public function new() {
a = 1;
}
}
```

Occurs at least on Haxe 4.0.5 through 4.2.5 and 6bcae15, with HL 1.11

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.