Wave icon indicating copy to clipboard operation
Wave copied to clipboard

Reject global const declarations without an initializer during semantic validation

Open LunaStev opened this issue 3 weeks ago • 0 comments

Problem

A source-level missing initializer passes semantic checking and reaches the LLVM invariant Constant must be initialized. Both scalar and aggregate const declarations are affected.

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.

const x:i32; fun main() -> i32{return x;}
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 exits 0; IR generation exits 1 with E9001. An unused const and a struct-typed const also reproduce.

Scope

Validate required const initializers at the declaration. Preserve the existing rules for uninitialized var/static storage.

Starting points: front/parser/src/verification.rs:420, llvm/src/codegen/ir.rs:954.

Completion criteria

  • [ ] Reject initialized-value omissions with an ordinary source diagnostic in check and both backend paths.
  • [ ] Keep valid const declarations working and retain the declaration span in human/JSON output.
  • [ ] Cover scalar/aggregate and used/unused declarations; preserve an existing requested output on failure.

This is a bounded newcomer task with the starting point and focused negative/positive checks above.

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

LunaStev avatar Nov 12 '26 12:11 LunaStev