HaxeFoundation / HaxeFoundation/haxe
Compilation Error - Invalid_argument("index out of bounds") | DCE full only
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
When I compile my project it runs through most of it and then outputs this:
Invalid_argument("index out of bounds")
UPDATE: I believe it's something due to dead code elimination. I believe the DCE is eliminating the type somehow and then the macro is bringing it back in. On DCE std or off it runs fine.
I get this when I am targeting HL/C. When I target hashlink, I don't get a compile error, but I get a JIT error where it can't find a function.
After cutting out portions of the project I can get the error to appear/re-appear with the addition and removal of a single function with no body. I have no idea why its happening.
I'm guessing that something is stopping the compiler from emitting the correct number of functions in some way but I don't know how the compiler works internally.
Some more error information would be helpful.
Below is the macro output that when generated makes the error code appear:
```
if (!activated) {
activated = true;
__clientAdd_listener__ = function(__entity__:hcqe.Entity, a:heaps.yojimbo.RemoteClient):Void clientAdd(a);
viewof_ffffffff_heapsyojimboremoteclient.activate();
viewof_ffffffff_heapsyojimboremoteclient.onAdded.add(__clientAdd_listener__);
viewof_ffffffff_heapsyojimboremoteclient.iter(__clientAdd_listener__);
onactivate();
}
```
Below is the same output with the function generation disabled. The error code no longer appears.
```
if (!activated) {
activated = true;
viewof_ffffffff_heapsyojimboremoteclient.activate();
viewof_ffffffff_heapsyojimboremoteclient.onAdded.add(__clientAdd_listener__);
viewof_ffffffff_heapsyojimboremoteclient.iter(__clientAdd_listener__);
onactivate();
}
```
The above was printed with the Haxe macro printer.
Simply assigning the anonymous function in the macro makes the error code appear.
__clientAdd_listener__ = function(__entity__:hcqe.Entity, a:heaps.yojimbo.RemoteClient):Void clientAdd(a);
If I change the type the error code also goes away.
Here is the Haxe -v output tail:
```
....
Typing haxe.ds._Vector.Vector_Impl_.copy
Typing haxe.ds._Vector.Vector_Impl_.join
Typing haxe.ds._Vector.Vector_Impl_.map
Typing haxe.ds._Vector.Vector_Impl_.sort
Generating hl: bin/server.c
Invalid_argument("index out of bounds")
```
Contributor guide
Assessment
This issue has not been assessed yet.