aboutsummaryrefslogtreecommitdiff
path: root/src/Sema.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-05-17 19:30:38 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-05-17 19:30:38 -0700
commit615d45da779842715a3ab65b59233e9cfb4fa122 (patch)
tree9c269e8fa9beded00954d82ebc0c95d56c485322 /src/Sema.zig
parent1d3f76bbda90f810a24845c15516235d91ee12ad (diff)
parent0dd0c9620d66afcfabaf3dcb21b636530fd0ccba (diff)
downloadzig-615d45da779842715a3ab65b59233e9cfb4fa122.tar.gz
zig-615d45da779842715a3ab65b59233e9cfb4fa122.zip
Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
Conflicts: * src/codegen/spirv.zig * src/link/SpirV.zig We're going to want to improve the stage2 test harness to print the source file name when a compile error occurs otherwise std lib contributors are going to see some confusing CI failures when they cause stage2 AstGen compile errors.
Diffstat (limited to 'src/Sema.zig')
-rw-r--r--src/Sema.zig15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/Sema.zig b/src/Sema.zig
index a902611087..920a615d6b 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -4229,19 +4229,18 @@ fn resolveSwitchItemVal(
switch_prong_src: Module.SwitchProngSrc,
range_expand: Module.SwitchProngSrc.RangeExpand,
) InnerError!TypedValue {
- const mod = sema.mod;
const item = try sema.resolveInst(item_ref);
// We have to avoid the other helper functions here because we cannot construct a LazySrcLoc
// because we only have the switch AST node. Only if we know for sure we need to report
// a compile error do we resolve the full source locations.
if (item.value()) |val| {
if (val.isUndef()) {
- const src = switch_prong_src.resolve(mod, block.src_decl, switch_node_offset, range_expand);
+ const src = switch_prong_src.resolve(sema.gpa, block.src_decl, switch_node_offset, range_expand);
return sema.failWithUseOfUndef(block, src);
}
return TypedValue{ .ty = item.ty, .val = val };
}
- const src = switch_prong_src.resolve(mod, block.src_decl, switch_node_offset, range_expand);
+ const src = switch_prong_src.resolve(sema.gpa, block.src_decl, switch_node_offset, range_expand);
return sema.failWithNeededComptime(block, src);
}
@@ -4285,7 +4284,7 @@ fn validateSwitchItemEnum(
const item_tv = try sema.resolveSwitchItemVal(block, item_ref, src_node_offset, switch_prong_src, .none);
const field_index = item_tv.ty.enumTagFieldIndex(item_tv.val) orelse {
const msg = msg: {
- const src = switch_prong_src.resolve(mod, block.src_decl, src_node_offset, .none);
+ const src = switch_prong_src.resolve(sema.gpa, block.src_decl, src_node_offset, .none);
const msg = try mod.errMsg(
&block.base,
src,
@@ -4317,8 +4316,9 @@ fn validateSwitchDupe(
) InnerError!void {
const prev_prong_src = maybe_prev_src orelse return;
const mod = sema.mod;
- const src = switch_prong_src.resolve(mod, block.src_decl, src_node_offset, .none);
- const prev_src = prev_prong_src.resolve(mod, block.src_decl, src_node_offset, .none);
+ const gpa = sema.gpa;
+ const src = switch_prong_src.resolve(gpa, block.src_decl, src_node_offset, .none);
+ const prev_src = prev_prong_src.resolve(gpa, block.src_decl, src_node_offset, .none);
const msg = msg: {
const msg = try mod.errMsg(
&block.base,
@@ -4355,7 +4355,7 @@ fn validateSwitchItemBool(
false_count.* += 1;
}
if (true_count.* + false_count.* > 2) {
- const src = switch_prong_src.resolve(mod, block.src_decl, src_node_offset, .none);
+ const src = switch_prong_src.resolve(sema.gpa, block.src_decl, src_node_offset, .none);
return sema.mod.fail(&block.base, src, "duplicate switch value", .{});
}
}
@@ -7584,4 +7584,3 @@ fn enumFieldSrcLoc(
}
} else unreachable;
}
-