aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Sema.zig9
-rw-r--r--src/Zcu.zig5
2 files changed, 11 insertions, 3 deletions
diff --git a/src/Sema.zig b/src/Sema.zig
index 978396e371..fb9b27a8cd 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -1824,7 +1824,14 @@ fn analyzeBodyInner(
);
const uncasted_cond = try sema.resolveInst(extra.data.condition);
const cond = try sema.coerce(block, Type.bool, uncasted_cond, cond_src);
- const cond_val = try sema.resolveConstDefinedValue(block, cond_src, cond, null);
+ const cond_val = try sema.resolveConstDefinedValue(
+ block,
+ cond_src,
+ cond,
+ // If this block is comptime, it's more helpful to just give the outer message.
+ // This is particularly true if this came from a comptime `condbr` above.
+ if (block.isComptime()) null else .{ .simple = .inline_loop_operand },
+ );
const inline_body = if (cond_val.toBool()) then_body else else_body;
try sema.maybeErrorUnwrapCondbr(block, inline_body, extra.data.condition, cond_src);
diff --git a/src/Zcu.zig b/src/Zcu.zig
index 8f35253509..c75cd5d40c 100644
--- a/src/Zcu.zig
+++ b/src/Zcu.zig
@@ -1864,15 +1864,16 @@ pub const SrcLoc = struct {
if (want_case_idx.isSpecial()) {
break case;
}
+ continue;
}
const is_multi = case.ast.values.len != 1 or
node_tags[case.ast.values[0]] == .switch_range;
- if (!want_case_idx.isSpecial()) switch (want_case_idx.kind) {
+ switch (want_case_idx.kind) {
.scalar => if (!is_multi and want_case_idx.index == scalar_i) break case,
.multi => if (is_multi and want_case_idx.index == multi_i) break case,
- };
+ }
if (is_multi) {
multi_i += 1;