Separate user function identities from compiler-generated C I/O symbols
Problem
User functions named printf or scanf collide with compiler-generated calls to the C runtime. Generated input-failure code can also resolve to a user exit function with an incompatible contract.
Reproduction and evidence
Audited canonical master 69a67c6e0fb700f37ee6114f5a66d37ee13771a5 (0.0.1-alpha-dev). Matching checkout-built compiler/std were used for compiler probes on Linux amd64 with Rust 1.89.0 and LLVM 21.1.8. Artifact inspection, mocked/projection checks and foreign-target object emission are identified below and are not native execution on those operating systems.
fun printf(x: i32) -> i32 { return x; } fun main() -> i32 { println("hello"); return 0; }
target/debug/wavec --std-root "$PWD/std" build repro.wave --emit=check
target/debug/wavec --std-root "$PWD/std" build repro.wave --emit=ir --out-dir out
Observed: semantic check succeeds, then LLVM verification fails with E9002. A user scanf(i32) plus float input also fails. IR inspection with a user exit(i32)->i32 shows the generated failure path referring to that function; that ABI-invalid path was not executed.
Scope
Handle the common symbol-identity cause across generated output, input and failure helpers. Preserve explicit extern/export(c) ABI names and evaluation order.
Starting points: llvm/src/statement/io.rs:49, llvm/src/statement/integer_io.rs:26.
Design discussion required
Choose how internal Wave identities coexist with external C names. Recommended: distinct internal identities/names while retaining explicit C linkage names. An alternative is a documented reserved-name restriction; it would reject previously accepted user code.
Please mention @LunaStev to discuss the design before starting implementation.
Completion criteria
- [ ] Ordinary user function names cannot redirect compiler-generated runtime calls.
- [ ] Valid user calls and explicit external bindings retain their ABI.
- [ ] Add printf/scanf/exit collision controls at O0/O2 without one issue per name.
Related: #737, #350. Related broad trackers or completed implementations are context, not claims that their entire scope is unfinished.