aboutsummaryrefslogtreecommitdiff
path: root/src/Sema.zig
diff options
context:
space:
mode:
authorgabeuehlein <gabeuehlein@gmail.com>2024-10-14 08:02:14 -0400
committerGitHub <noreply@github.com>2024-10-14 15:02:14 +0300
commit7b8fc18c666ba6952ad1571fbed4cc48e81f647d (patch)
treea9ec04b57aa063f899bce4a65cb7aa4419d9b21b /src/Sema.zig
parent9fd61f7460950a4124f8a9d6eb31a40f03ecd5a7 (diff)
downloadzig-7b8fc18c666ba6952ad1571fbed4cc48e81f647d.tar.gz
zig-7b8fc18c666ba6952ad1571fbed4cc48e81f647d.zip
Sema: fail if analyzing return in `noreturn`-declared function before coercing `undefined`
Just switches logic around in coerceExtra to check for returning in a noreturn function before coercing undefined to anything
Diffstat (limited to 'src/Sema.zig')
-rw-r--r--src/Sema.zig10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/Sema.zig b/src/Sema.zig
index 1de0d73808..1250a06a9c 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -30346,11 +30346,6 @@ fn coerceExtra(
else => {},
}
- // undefined to anything. We do this after the big switch above so that
- // special logic has a chance to run first, such as `*[N]T` to `[]T` which
- // should initialize the length field of the slice.
- if (maybe_inst_val) |val| if (val.toIntern() == .undef) return pt.undefRef(dest_ty);
-
if (!opts.report_err) return error.NotCoercible;
if (opts.is_ret and dest_ty.zigTypeTag(zcu) == .noreturn) {
@@ -30368,6 +30363,11 @@ fn coerceExtra(
return sema.failWithOwnedErrorMsg(block, msg);
}
+ // undefined to anything. We do this after the big switch above so that
+ // special logic has a chance to run first, such as `*[N]T` to `[]T` which
+ // should initialize the length field of the slice.
+ if (maybe_inst_val) |val| if (val.toIntern() == .undef) return pt.undefRef(dest_ty);
+
const msg = msg: {
const msg = try sema.errMsg(inst_src, "expected type '{}', found '{}'", .{ dest_ty.fmt(pt), inst_ty.fmt(pt) });
errdefer msg.destroy(sema.gpa);