Files
sx/examples/1188-diagnostics-run-no-main.sx
agra 6ed29621ad fix: diagnose missing 'main' instead of segfaulting on 'sx run' (issue 0137)
A program with no 'main' reached the JIT entry-point call with a garbage
address (ORC reports lookup success but leaves main_addr degenerate), then
called it -> SIGSEGV. Add a pre-JIT entry-point check in main.zig that emits
'error: no main function found' and exits non-zero before codegen, plus a
defensive main_addr==0 guard in target.zig runJITFromObject as a backstop.

Regression: examples/1188-diagnostics-run-no-main.sx
2026-06-21 09:10:30 +03:00

13 lines
464 B
Plaintext

// `sx run` on a program with no `main` must emit a clean diagnostic and exit
// non-zero — never call into a garbage JIT address and segfault. A pre-JIT
// entry-point check in main.zig (plus a defensive `main_addr == 0` backstop in
// target.zig's runJITFromObject) replaces the old silent garbage-pointer call.
//
// Regression (issue 0137).
#import "modules/std.sx";
// Intentionally no `main` — only a helper.
greet :: () {
print("unreachable\n");
}