HaxeFoundation / HaxeFoundation/haxe
Compiler error when using @:nativeGen on interface and an implementing class on C++ target
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
The issue appears to be in generating the inheritance list. To reproduce:
Test.hx:
```
@:nativeGen
interface ITest {
public function foo():Void;
}
@:nativeGen
class TestImpl implements ITest {
public function foo() {}
}
```
Compile with:
`haxe -cpp test Test.hx`
This produces the following class definition in TestImpl.h:
```
class HXCPP_CLASS_ATTRIBUTES TestImpl , public virtual ITest
{
public:
void foo();
};
```
It looks like the error might be in gencpp.ml, in generate_class_header. dump_native_interfaces always emits a , first, but is called from a branch of code that will not emit an initial base class (a few lines below, `else if (super=="") then...`).
It seems like this only affects native classes implementing native interfaces (removing @:nativeGen from ITest compiles, but TestImpl loses that inheritance).
Happy to submit a PR with a patch.
Contributor guide
Research direction
Start with gencpp.ml, especially generate_class_header and dump_native_interfaces. Reproduce the issue with the Test.hx example and `haxe -cpp test Test.hx`, then inspect the generated TestImpl.h. Done means the C++ target compiles for native classes implementing native interfaces and emits a valid inheritance list.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100