Commit a483e38df6

Timon Kruiper <timonkruiper@gmail.com>
2021-04-07 13:27:36
stage2: fix bug where invalid ZIR was generated
The following code caused an assertion to be hit: ``` pub fn main() void { var e: anyerror!c_int = error.Foo; const i = e catch 69; assert(69 - i == 0); } ```
1 parent ac14b52
Changed files (1)
src/Module.zig
@@ -2863,8 +2863,9 @@ fn astgenAndSemaFn(
 
         _ = try AstGen.expr(&gen_scope, params_scope, .none, body_node);
 
-        if (gen_scope.instructions.items.len == 0 or
-            !astgen.instructions.items(.tag)[gen_scope.instructions.items.len - 1]
+        const inst_tags = astgen.instructions.items(.tag);
+        if (inst_tags.len == 0 or
+            !inst_tags[inst_tags.len - 1]
             .isNoReturn())
         {
             // astgen uses result location semantics to coerce return operands.