mirror of
https://github.com/ziglang/zig.git
synced 2026-02-04 05:33:39 +00:00
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:
parent
ac14b52e85
commit
a483e38df6
@ -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.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user