HaxeFoundation / HaxeFoundation/haxe
Can't use defineType to create a TDField in a module that already has other module level fields
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
I'm using haxe 4.2.5
```haxe
class Macro {
public static macro function myMacro():Expr {
Context.defineType({
name: "baz0",
kind: TDField(FVar(null, macro "hello")),
fields: [],
pos: Context.currentPos(),
pack: ["foo", "Bar"],
});
Context.defineType({
name: "baz1",
kind: TDField(FVar(null, macro "hello")),
fields: [],
pos: Context.currentPos(),
pack: ["foo", "Bar"],
});
return macro $p{["foo", "Bar", "baz1"]};
}
}
```
Running this macro will result in the error `Type name foo._Bar.Bar_Fields_ is redefined from module foo.Bar`
Same will happen if you call defineType only once but use a module that already had module level fields in it as target.
I believe this is creating the class `Bar_fields_` with kind `KModuleFields` each time and that causes the collision. I'm not sure if this is actually intended or a bug.
Contributor guide
Assessment
This issue has not been assessed yet.