Description
The compiler does not emit W2011 when a function declares named return values in its signature but the function body never declares variables matching those names. Named return values serve as documentation — if the programmer names them but then never creates corresponding variables, the names are misleading.
Note: E3080 already rejects return statements that don't return the exact named variables. W2011 catches the earlier case where the named return identifiers have no corresponding variable declarations in the function body at all.
Repro
do divide(a int, b int) -> (quotient int, remainder int) {
mut q int = a / b
mut r int = a % b
return q, r
}
do main() {
mut q, r = divide(10, 3)
println(q)
println(r)
}
Expected: Compiler emits W2011 on the function definition — quotient and remainder are declared as named return values but no variables with those names exist in the function body.
Actual: No warning emitted (E3080 fires on the return statement, but the signature mismatch goes undiagnosed).
Where to look
ezc/src/typechecker/typechecker.c — after check_block() processes the function body (around line 6062). Iterate tc->current_return_names and check whether each name exists as a symbol in the function scope. If not, emit W2011 on the function signature.
Register W2011 in ezc/src/util/error_codes.h if not already present, and run ./scripts/generate_errors.sh.
Description
The compiler does not emit W2011 when a function declares named return values in its signature but the function body never declares variables matching those names. Named return values serve as documentation — if the programmer names them but then never creates corresponding variables, the names are misleading.
Note: E3080 already rejects
returnstatements that don't return the exact named variables. W2011 catches the earlier case where the named return identifiers have no corresponding variable declarations in the function body at all.Repro
Expected: Compiler emits W2011 on the function definition —
quotientandremainderare declared as named return values but no variables with those names exist in the function body.Actual: No warning emitted (E3080 fires on the return statement, but the signature mismatch goes undiagnosed).
Where to look
ezc/src/typechecker/typechecker.c— aftercheck_block()processes the function body (around line 6062). Iteratetc->current_return_namesand check whether each name exists as a symbol in the function scope. If not, emit W2011 on the function signature.Register W2011 in
ezc/src/util/error_codes.hif not already present, and run./scripts/generate_errors.sh.