From ce9ae21cf4dcc39a99e5c96abb00c9c599d8fbc0 Mon Sep 17 00:00:00 2001 From: Techatrix <19954306+Techatrix@users.noreply.github.com> Date: Tue, 7 Mar 2023 12:45:54 +0100 Subject: [PATCH] fix lastToken on tagged union with invalid members --- src/ast.zig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ast.zig b/src/ast.zig index ef01668..9f65188 100644 --- a/src/ast.zig +++ b/src/ast.zig @@ -572,7 +572,9 @@ pub fn lastToken(tree: Ast, node: Ast.Node.Index) Ast.TokenIndex { => { end_offset += 2; // for the comma/semicolon + rparen/rbrace const params = tree.extraData(datas[n].rhs, Node.SubRange); - std.debug.assert(params.end > params.start); + if (params.end - params.start == 0) { + return main_tokens[n] + end_offset; + } n = tree.extra_data[params.end - 1]; // last parameter }, .@"switch" => {