Issue #3000: Lowering: a by-reference Copy parameter read as a value is not dereferenced

Open and answer this issue on GitHub.

ready · opened 2026-11-30 · updated 2026-11-30 · 0 comments

Found while building “nikaia.proofs: a trace per walked function, adopted without a replay; –search-unproved” (#2991).

The lowering passes a Copy enum parameter by reference (&EmitTail). Used as the value of an if/else arm, the Rust it writes does not compile:

// emit_core_if_expr, emit_core_leaves.nika
let then_tail = if else_block == null { EmitTail::Statement } else { tail }

rustc: E0308 “if and else have incompatible types: expected EmitTail, found &EmitTail”.

Expected: a by-reference Copy parameter read in value position lowers to *tail.

Workaround in the tree: crates/nikaia-std/src/compiler/emit_core_leaves.nika:909 writes tail.clone(). Remove it with the fix.

To build

  1. In the lowering of parameter reads in value position, dereference a by-reference parameter whose type is Copy (an if/match arm value, a let initializer, a return).
  2. Test in tests/compiler/tests/: a Copy enum parameter as an if/else arm value, with a .stdout.
  3. Replace tail.clone() at emit_core_leaves.nika:909 with tail, run lower-std, and check that lowered/ builds.

Done when the test passes and the workaround is gone.


Generated by Claude Code

Back to Open Issues