HaxeFoundation / HaxeFoundation/haxe

[cpp] Bad code generation for class static references

Open
#12,348 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

```haxe
class Main {
static function main() {
final dist = MathLib.dist.between(2, 1);
trace(dist);
}
}

class MathLib {
public static final dist = Distance;
}

class Distance {
public static function between(x:Int, x2:Int):Int {
return x - x2;
}
}
```
```hxml
-cp src
-D analyzer-optimize
-main Main
--cpp bin/cpp
```
There is one cpp compilation error with `class Distance` and two if this class is `private`
```
Error: ./src/Main.cpp:35:40: error: no member named '_Main' in the global namespace; did you mean 'Main'?
35 | HXDLIN( 4) ::haxe::Log_obj::trace(::_Main::Distance_obj::between(2,1),::hx::SourceInfo(HX_("src/Main.hx",9a,7a,30,a1),4,HX_("Main",59,64,2f,33),HX_("main",39,38,56,48)));
| ~~^~~~~
```

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.