authorgravatar for john.schmidt.h@gmail.comJohn Schmidt <john.schmidt.h@gmail.com> 2024-02-21 00:15:49+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-02-26 07:01:32+00:00
log723d13f8314a88f75a1068db7408677d8cc0c165
treea23f97fa74b8ef4f9bb198770909e3bb0bb0dd26
parent9dda2eb1abe675a99ff5d7ad85454b1cc5946c95

AstGen: fix OoB crash on `ast-check -t`

The `decl_node` was offset from the wrong source node.

1 files changed, 2 insertions(+), 2 deletions(-)

src/AstGen.zig+2-2
...@@ -4298,7 +4298,7 @@ fn fnDecl(...@@ -4298,7 +4298,7 @@ fn fnDecl(
42984298
4299 if (!fn_gz.endsWithNoReturn()) {4299 if (!fn_gz.endsWithNoReturn()) {
4300 // As our last action before the return, "pop" the error trace if needed4300 // As our last action before the return, "pop" the error trace if needed
4301 _ = try gz.addRestoreErrRetIndex(.ret, .always, decl_node);4301 _ = try fn_gz.addRestoreErrRetIndex(.ret, .always, decl_node);
43024302
4303 // Add implicit return at end of function.4303 // Add implicit return at end of function.
4304 _ = try fn_gz.addUnTok(.ret_implicit, .void_value, tree.lastToken(body_node));4304 _ = try fn_gz.addUnTok(.ret_implicit, .void_value, tree.lastToken(body_node));
...@@ -4746,7 +4746,7 @@ fn testDecl(...@@ -4746,7 +4746,7 @@ fn testDecl(
4746 if (fn_block.isEmpty() or !fn_block.refIsNoReturn(block_result)) {4746 if (fn_block.isEmpty() or !fn_block.refIsNoReturn(block_result)) {
47474747
4748 // As our last action before the return, "pop" the error trace if needed4748 // As our last action before the return, "pop" the error trace if needed
4749 _ = try gz.addRestoreErrRetIndex(.ret, .always, node);4749 _ = try fn_block.addRestoreErrRetIndex(.ret, .always, node);
47504750
4751 // Add implicit return at end of function.4751 // Add implicit return at end of function.
4752 _ = try fn_block.addUnTok(.ret_implicit, .void_value, tree.lastToken(body_node));4752 _ = try fn_block.addUnTok(.ret_implicit, .void_value, tree.lastToken(body_node));