E3028

E3028 — A function with a non-void return type whose body can complete without returning. Reported here rather than left to codegen, where it surfaced as an MLIR verifier message naming an operation, with no source location.

What the compiler reports

E3028{{.*}}'finishes' is declared `-> !`, so it must never return, but its body can finish

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
//
// A function declared `-> !` must not return: not by reaching the end of its body, and not with
// `return`.
//
fn finishes(x : i32) -> ! {
  if x > 0 {
    panic("positive");
  }
}

fn returns() -> ! {
  return;
}

fn main() -> i32 {
  return 0;
}

From tests/frontend/fail/never_returning_function_that_returns.vx, which asserts this diagnostic on every commit.

Related