HaxeFoundation / HaxeFoundation/haxe
[macro] -D js-es=6 will throw Must call `super()` constructor before accessing `this`
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
I found is this line cause for error. target for js
haxe version: 4.1.5 or haxe nightly build .
```haxe
f.meta.push({name: ":keep", pos: Context.currentPos()});
```
```haxe
import haxe.macro.Type.ClassType;
import haxe.macro.Context;
import haxe.macro.Expr;
@:remove @:autoBuild(CCG.buildFields())
extern interface CCGen {}
class CCG {
static var inClass:ClassType;
macro public static function buildFields():Array {
var fields:Array = Context.getBuildFields();
for (f in fields) {
f.meta.push({name: ":keep", pos: Context.currentPos()});
}
return fields;
}
}
```
```haxe
import CCG.CCGen;
extern class Component {
function new();
}
class Main extends Component implements CCGen {
@:property
public var arrayFloat:Array = [];
public static function main() {}
}
```
Contributor guide
Research direction
Reproduce the example with Haxe 4.1.5 or a nightly build using -D js-es=6, focusing on the CCG.buildFields macro and its f.meta.push call. Check the generated JavaScript and compiler handling of the macro-added :keep metadata; done means the provided example no longer produces the super() before this error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100