Wave icon indicating copy to clipboard operation
Wave copied to clipboard

Validate incompatible extern declarations sharing one native symbol

Open LunaStev opened this issue 3 weeks ago • 0 comments

Problem

Different Wave names may declare the same C symbol with incompatible signatures. Both pass semantic validation; later calls find the first LLVM declaration and fail a HIR type invariant.

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.

extern(c,"abs") fun abs1(i32)->i32; extern(c,"abs") fun abs2(i64)->i64;fun main()->i32{return abs2(-3) as i32;}
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: check 0, IR E9001 with an i32/i64 HIR evaluation-type disagreement. The same two aliases with identical i32 signatures are a passing control. The invalid C ABI call was not executed.

Scope

Define native-symbol declaration compatibility across parameter/result types, variadic status and calling convention, retaining legal equivalent aliases.

Starting points: llvm/src/expression/rvalue/calls.rs:1, front/parser/src/verification.rs:1.

Design discussion required

Recommended: reject incompatible canonical ABI signatures for one native symbol and allow ABI-equivalent aliases. If multiple intentional ABI views are desired, that needs an explicit supported contract rather than incidental first-declaration lookup.

Please mention @LunaStev to discuss the design before starting implementation.

Completion criteria

  • [ ] Incompatible declarations are diagnosed with both declaration locations before backend failure.
  • [ ] Compatible aliases remain usable.
  • [ ] Tests distinguish explicit native-symbol collisions from generated-runtime-name collisions.

Related: #350. Related broad trackers or completed implementations are context, not claims that their entire scope is unfinished.

LunaStev avatar Nov 12 '26 12:11 LunaStev