HaxeFoundation / HaxeFoundation/haxe
[jvm] Compiler failure when attempting to relocate `haxe.root.Array`
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
## Background
I am currently working on a [Haxe library](https://github.com/EliteMasterEric/haxe-shade) to apply shading to a targeted package or module. The modules the macro is applied to should be generated at a new location of the user's choice.
For example, `--macro haxe.shade.Shade.applyPackage("test", "foo.bar")` will cause `src/test/CoolClass.hx` to generate as `foo.bar.CoolClass`, rather than `test.CoolClass`.
This is being developed for a Minecraft modding project I am working on, where, if multiple JARs contain conflicting classpaths, the application will fail to load. Since this includes any modules in the `haxe` package, this has been a focus of my development for this library.
The module functions by applying the `@:native` metadata to the class, and removing any existing instances of that metadata to avoid overlap.
Note this library was originally in the form of a [Haxe feature proposal](https://github.com/HaxeFoundation/haxe-evolution/pull/108) from April of this year. The library is now in development after my project's switch to the JVM target (made possible by the resolution of #11023) mandated that shading no longer be done by Gradle.
## The Issue
I am trying to move the `haxe.root.Array` module such that it is generated in the location of my choice, say `foo.bar.haxe.Array`.
Upon applying the macro, I receive this error:
```
Compiler failure
Please submit an issue at https://github.com/HaxeFoundation/haxe/issues/new
Attach the following information:
Haxe: 4.3.1; OS type: windows;
File "src/generators/genjvm.ml", line 2028, characters 11-18
Called from file "src/generators/genjvm.ml", line 1858, characters 3-13
Called from file "src/generators/genjvm.ml", line 2064, characters 5-15
Called from file "src/generators/genjvm.ml", line 2068, characters 3-10
Called from file "src/generators/genjvm.ml", line 2492, characters 3-21
Called from file "list.ml", line 110, characters 12-15
Called from file "list.ml", line 110, characters 12-15
Called from file "src/generators/genjvm.ml", line 2593, characters 2-49
Called from file "src/generators/genjvm.ml", line 2631, characters 2-63
Called from file "list.ml", line 110, characters 12-15
Called from file "src/core/timer.ml", line 199, characters 11-14
Called from file "src/generators/genjvm.ml", line 3079, characters 1-54
Called from file "src/compiler/generate.ml", line 99, characters 2-14
Called from file "src/compiler/compiler.ml", line 332, characters 29-64
Called from file "src/compiler/compiler.ml", line 347, characters 1-5
Called from file "src/compiler/compiler.ml", line 434, characters 2-162
Called from file "src/compiler/compiler.ml", line 408, characters 2-9
Called from file "src/compiler/compiler.ml", line 630, characters 5-43
Called from file "src/compiler/compiler.ml", line 640, characters 13-22
Called from file "src/compiler/server.ml", line 979, characters 1-39
Called from file "src/compiler/haxe.ml", line 53, characters 0-56
File "src/core/globals.ml", line 156, characters 1-7: Assertion failed
```
## Reproduction
Download [the library](https://github.com/EliteMasterEric/haxe-shade), use `haxelib dev` to install as a library, then compile `./test/issue-11361/compile.hxml`, and see the error.
Contributor guide
Research direction
Reproduce the failure with the haxe-shade library and test/issue-11361/compile.hxml. Then inspect src/generators/genjvm.ml around lines 2028, 1858, and 2064, where the stack trace enters JVM generation. Done means relocating haxe.root.Array no longer causes the compiler assertion failure.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100