Commit 723d13f831

John Schmidt <john.schmidt.h@gmail.com>
2024-02-21 00:15:49
AstGen: fix OoB crash on `ast-check -t`
The `decl_node` was offset from the wrong source node.
1 parent 9dda2eb
Changed files (1)
src/AstGen.zig
@@ -4298,7 +4298,7 @@ fn fnDecl(
 
         if (!fn_gz.endsWithNoReturn()) {
             // As our last action before the return, "pop" the error trace if needed
-            _ = try gz.addRestoreErrRetIndex(.ret, .always, decl_node);
+            _ = try fn_gz.addRestoreErrRetIndex(.ret, .always, decl_node);
 
             // Add implicit return at end of function.
             _ = try fn_gz.addUnTok(.ret_implicit, .void_value, tree.lastToken(body_node));
@@ -4746,7 +4746,7 @@ fn testDecl(
     if (fn_block.isEmpty() or !fn_block.refIsNoReturn(block_result)) {
 
         // As our last action before the return, "pop" the error trace if needed
-        _ = try gz.addRestoreErrRetIndex(.ret, .always, node);
+        _ = try fn_block.addRestoreErrRetIndex(.ret, .always, node);
 
         // Add implicit return at end of function.
         _ = try fn_block.addUnTok(.ret_implicit, .void_value, tree.lastToken(body_node));