E3007
E3007 — If branch type mismatch
What the compiler reports
Error[E3007]{{.*}}incompatible types: i32 and void
1 error(s) emitted
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
//
// Part of the Vx Project, under the Apache License v2.0 with LLVM Exceptions.
// See LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// `2;` is a statement, so a branch ending in it has no value to give the `if`.
fn main() -> i32 {
let c = true;
let y = if c {
40
} else {
2;
};
return y;
}
From tests/frontend/fail/if_branch_ending_in_semicolon_has_no_value.vx, which asserts this diagnostic on every commit.