commit a483e38df62f73dc0cdadee6faf3e083094210d4 (tree)
parent ac14b52e85f857f7f70846d22ea18ea265acb91a
Author: Timon Kruiper <timonkruiper@gmail.com>
Date: Wed, 7 Apr 2021 13:27:36 +0200
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);
}
```
Diffstat:
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/Module.zig b/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.