E3002
E3002 — Type mismatch in return
What the compiler reports
E3002{{.*}}this function returns i32, so `return` needs a value
The fragments the test suite holds the compiler to. An ellipsis marks text the test does not constrain; the emitted message also carries a source location.
A program that triggers it
//
// `return;` is an exit, not a value. A function that promises one has to produce it.
fn promises_an_i32(x : i32) -> i32 {
if x > 0 {
return;
}
return 1;
}
fn promises_a_tensor(x : i32) -> Tensor<f32, [4]> {
return;
}
fn main() -> i32 {
return 0;
}
From tests/frontend/fail/bare_return_needs_a_value.vx, which asserts this diagnostic on every commit.