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);
}
```
This commit is contained in:
Timon Kruiper 2021-04-07 13:27:36 +02:00
parent ac14b52e85
commit a483e38df6

View File

@ -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.