Repository navigation
Description
Problem
Omitted default parameters are accepted for method-style calls but are not added to the emitted call. front/parser/src/generics.rs rewrites method arguments without the default expansion used for ordinary function calls; llvm/src/expression/rvalue/calls.rs then emits too few LLVM arguments.
Reproduction
Tested at 5002a93a4a233032553aa6c6e3639d88e93c53bf on Fedora Linux 43 amd64 with LLVM 21.1.8. Build the current compiler with LLVM_SYS_211_PREFIX=/usr/lib64/llvm21 cargo build --locked --release --jobs 2.
Save as repro.wave:
struct S {
x: i32;
fun value(self: S, extra: i32 = 2) -> i32 {
return self.x + extra;
}
}
fun main() -> i32 {
var s: S = S { x: 3 };
return s.value() - 5;
}
target/release/wavec check repro.wave
target/release/wavec build repro.wave -O0 --emit=ir,obj,bin --out-dir /tmp/wave-audit-reproRepeat the build with -O2.
check succeeds. Both O0/O2 builds fail with E9002 and LLVM verification reports Incorrect number of arguments passed to called function! for call i32 @S_value(%S %load_s).
Writing s.value(2) builds and returns 0. Moving value to a free function reproduces the failure with method-style s.value(), while value(s) expands the default and returns 0. These controls were executed at O0/O2.
Scope
Apply the existing literal-default contract after resolving a method or free-function fallback. Keep receiver accounting, explicit arguments, generic specialization and source provenance consistent. Evaluate the receiver and each supplied argument once. No new default-expression syntax is required. Difficulty: medium.
Completion criteria
- Direct methods and free-function fallback calls expand omitted defaults just as ordinary calls do.
- Explicit/default argument combinations and invalid arity receive consistent checking and lowering.
- O0/O2 regressions cover value/pointer receivers, scalar defaults and generic methods; receiver side effects occur once.
Activity