From 723d13f8314a88f75a1068db7408677d8cc0c165 Mon Sep 17 00:00:00 2001 From: John Schmidt Date: Wed, 21 Feb 2024 00:15:49 +0100 Subject: [PATCH] AstGen: fix OoB crash on `ast-check -t` The `decl_node` was offset from the wrong source node. --- src/AstGen.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/AstGen.zig b/src/AstGen.zig index b080a36d4f..9555aec681 100644 --- a/src/AstGen.zig +++ b/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));