aboutsummaryrefslogtreecommitdiff
path: root/src/Sema.zig
diff options
context:
space:
mode:
authorMitchell Hashimoto <mitchell.hashimoto@gmail.com>2022-03-19 10:58:33 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-03-19 15:55:23 -0400
commit67665286575d406769000b3f3e80d4d03d2cab2b (patch)
tree7cdd00995419c5ced2b1e558975cceca8d76635c /src/Sema.zig
parent69e6d455ce8e21835ec3ce268a0533e0e7666e8b (diff)
downloadzig-67665286575d406769000b3f3e80d4d03d2cab2b.tar.gz
zig-67665286575d406769000b3f3e80d4d03d2cab2b.zip
stage2: fix crash that could happen if `as` zir fails
Example scenario: test { const a: i32 = blk: { if (false) break :blk 24; }; _ = a; } Prior to this, this would panic the compiler with a source needed error. This provides the source as `sema.src`. This is not ideal, since the line it points to is pretty far from the true issue. (One block out) But, this prevents the compiler from straight up crashing and follows a pattern used by similar ZIR which don't provide a src loc.
Diffstat (limited to 'src/Sema.zig')
-rw-r--r--src/Sema.zig2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/Sema.zig b/src/Sema.zig
index 94db6e80b9..ff33f56c67 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -6362,7 +6362,7 @@ fn zirAs(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst
defer tracy.end();
const bin_inst = sema.code.instructions.items(.data)[inst].bin;
- return sema.analyzeAs(block, .unneeded, bin_inst.lhs, bin_inst.rhs);
+ return sema.analyzeAs(block, sema.src, bin_inst.lhs, bin_inst.rhs);
}
fn zirAsNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {