This is the Haxe compiler repository. Haxe is an open source toolkit that allows building cross-platform tools and applications. The repository contains:
- The Haxe compiler - written in OCaml, targets multiple platforms (JavaScript, C++, JVM, Lua, PHP, Python, HashLink, NekoVM, Flash, and its own interpreter)
- The Haxe standard library - located in
std/, written in Haxe - Test suite - located in
tests/, particularly unit tests intests/unit/
- Language: The compiler is written in OCaml (version 5.0+)
- Build tool: Uses
dunebuild system and Make - Makefile: For Unix/Linux/macOS, use
Makefile; for Windows, useMakefile.win - Build commands:
make- Build everythingmake haxe- Build only the compileropam install haxe --deps-only- Install OCaml dependencies (after pinning the local checkout)opam exec -- make ADD_REVISION=1 -f Makefile.win -s -j haxe- Typical Windows compiler build command used in CI/tasksdune build- Build using dune directly
- OCaml 5.0+ (managed via OPAM)
- Native libraries: PCRE2, zlib, mbedTLS 3.x (4.x not yet supported)
- Neko VM (for building haxelib)
syntax/- Lexer and parsertyping/- Type system and type inferencecodegen/- Code generation utilitiesgenerators/- Target-specific code generators (JVM, JS, C++, etc.)optimization/- Optimization passesmacro/- Macro systemcontext/- Compiler context and statefilters/- AST transformation filters
- Core types (Array, String, Map, etc.) at root level
haxe/andsys/- Platform-independent standard library packages- Platform-specific directories (e.g.,
cpp/,js/,jvm/,python/, etc.)- Each platform can shadow standard library implementations via
platform/_std/directory - Example:
std/cpp/_std/haxe/ds/StringMap.hxshadows the genericstd/haxe/ds/StringMap.hx
- Each platform can shadow standard library implementations via
unit/- Unit tests written in Haxeunit/src/unit/issues/- Regression tests for specific issues (success cases)
server/- Modern version of display tests, generally preferredmisc/- Tests expected to produce failures- Platform-specific subdirectories (e.g.,
misc/cpp/for C++-specific tests)
- Platform-specific subdirectories (e.g.,
nullsafety/- Tests related to the null-safety featureoptimization/- Optimization tests that check concrete code output on JavaScript targetsys/- Tests specific to thestd/syspackage (sys-targets only: excludes Flash and JavaScript)threads/- Thread-related tests, generally forstd/sys/threadpackage (threaded targets only)
For tests that assert success, add a regression test to tests/unit/src/unit/issues/:
- Create a file:
tests/unit/src/unit/issues/Issue{NUMBER}.hx - Follow this pattern:
package unit.issues;
class Issue12345 extends Test {
#if target_name // Use conditionals for target-specific tests
function test() {
eq(actualValue, expectedValue);
}
#end
}For expected failures, use tests/misc instead, with platform-specific subdirectories as needed.
Note: Not all tests belong in the unit tests. See the Tests section above for other test directories and their purposes.
The Javascript tests are good for checking output syntax.
# Compile for a specific target
haxe --cwd tests/unit compile-{target}.hxml
# Run the tests
# Example for Lua:
lua bin/unit.lua
# Example for JavaScript:
node bin/unit.js- Follow existing code style in the codebase
- Use tabs for indentation (as seen in existing files)
- Keep functions focused and modular
- Document complex algorithms or non-obvious logic
- Use tabs for indentation
- Follow Haxe naming conventions:
- Classes: PascalCase
- Functions/variables: camelCase
- Constants: UPPER_CASE
- Target-specific code should use conditional compilation (
#if target)
- Identify the relevant module in
src/ - Make minimal, focused changes
- Build:
make haxe - Add regression tests if fixing a bug
- Execute the appropriate tests in one of the tests subdirectories
- Even if everything works, check some output to ensure it looks good
- Modify files in
std/ - Consider cross-platform compatibility
- Test on relevant targets
- Update API documentation if needed
- Use
-D dump=prettyto dump readable AST todump/directory - Check generated code for specific targets
- Most targets produce readable output for inspection
- Changes must consider impact on all supported targets
- Target-specific behavior should be clearly documented
- Use conditional compilation appropriately
- The compiler and standard library must maintain backwards compatibility
- Breaking changes require careful consideration and deprecation process
- The compiler should be fast and efficient
- Standard library should have minimal overhead
- Optimization passes should not break correctness
- Try to avoid code duplication, especially in the OCaml code
- Prefer top-level functions over closures for functions with large bodies
- Comments are good, but keep the amount reasonable
- CI runs on GitHub Actions (see
.github/workflows/) - Tests run on multiple platforms (Windows, Linux, macOS)
- Both x86_64 and ARM64 architectures are tested
- All targets are tested in CI
- When making changes related to coroutines, run the appropriate target test at https://github.com/HaxeFoundation/hxcoro/tree/master/tests
When investigating CI failures, use the GitHub MCP tools as follows:
- Use
list_workflow_runsto find the relevant workflow run ID for the failing branch/PR - Use
list_workflow_jobsto identify which jobs failed (look forconclusion != "success") - Use
get_job_logswithfailed_only: trueandreturn_content: trueto get log content- Important: Use a moderate
tail_linesvalue (100-200) to avoid being flooded by post-step cleanup output that always appears at the very end of logs - The actual test failure output typically appears near the bottom of the test step output, before the post-step cleanup lines
- Look for keywords like
FAILED,error,exit code,assert,exceptionto locate the relevant failure
- Important: Use a moderate
- The job name contains the target and platform, e.g.
linux-test (macro, x86)means the macro target on Linux x86
- Building instructions:
extra/BUILDING.md - Contributing guidelines:
CONTRIBUTING.md - Unit test guidelines:
tests/unit/README.md - Main documentation: https://haxe.org/documentation/
- Manual: https://haxe.org/manual/
- The haxelib command is available in your PATH (the workspace root is added to PATH during setup)
- Run
haxelib setupto set up the repository path - Use
haxelib git utest https://github.com/haxe-utest/utestfor utest - A git-cloned library can be set as a development library via
haxelib dev libname path - If your changes are related to coroutines, run some of the tests in https://github.com/HaxeFoundation/hxcoro
- Humans are fallible
- If you feel like a given task makes little or no sense, point out why and suggest an alternative
- Keep an open mind regarding specific ways to address a given issue