From 0bf9602d7bb063a9b9435b5621756b36ca3a5988 Mon Sep 17 00:00:00 2001 From: Alexandros Naskos Date: Sun, 15 Nov 2020 20:37:00 +0200 Subject: [PATCH] Fixed infinite loop when analyzing variable declarations like `const A = A;` for semantic token highlighting --- src/analysis.zig | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/analysis.zig b/src/analysis.zig index 43d62e1..4864ab5 100644 --- a/src/analysis.zig +++ b/src/analysis.zig @@ -569,7 +569,13 @@ pub fn resolveTypeOfNodeInternal( if (try lookupSymbolGlobal(store, arena, handle, handle.tree.getNodeSource(node), handle.tree.token_locs[node.firstToken()].start)) |child| { switch (child.decl.*) { - .ast_node => |n| if (n == node) return null, + .ast_node => |n| { + if (n == node) return null; + if (n.castTag(.VarDecl)) |var_decl| { + if (var_decl.getInitNode()) |init_node| + if (init_node == node) return null; + } + }, else => {}, } return try child.resolveType(store, arena, bound_type_params);