HaxeFoundation / HaxeFoundation/haxe

Unknown symbol found when compiled to Python with argument '--dce no'

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

Description

# Info
Haxe Compiler 4.3.7
# Reproduction
1. Create a file Test.hx containing:
```hx
class Test {
static function main() {
trace("Hello world!");
}
}
```
2. Run the following command: `haxe --python a.py -m Test --dce no`.
3. Try compiling a.py using Cython: `cython a.py`
4. An error message will be shown:
```
Error compiling Cython file:
------------------------------------------------------------
...
return list
if (name == "Math"):
return Math
if (name == "String"):
return str
cl = _hx_classes.get(name,None)
^
------------------------------------------------------------
a.py:1546:13: undeclared name not builtin: _hx_classes
```

# Additional details
To ensure that error is valid, I checked where _hx_classes is defined in the source, but nothing.
```
$ grep _hx_classes a.py -C5
return list
if (name == "Math"):
return Math
if (name == "String"):
return str
cl = _hx_classes.get(name,None)
tmp = None
if (cl is not None):
o = cl
tmp = (not (((o is not None) and ((HxOverrides.eq(o,str) or python_lib_Inspect.isclass(o))))))
else:
$
```

Contributor guide

Open the contributing guide

Research direction

Start with the generated a.py from `haxe --python a.py -m Test --dce no`, inspect the `_hx_classes` reference, and trace it back through the compiler's Python output path. Run the reported Cython compilation step; done means the generated file no longer references an undeclared `_hx_classes` symbol.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.