From 77e39a8da887f6f2768a1f261d660e6795198f05 Mon Sep 17 00:00:00 2001 From: Techatrix <19954306+Techatrix@users.noreply.github.com> Date: Fri, 9 Jun 2023 23:13:36 +0200 Subject: [PATCH] clear using_trail when calling resolveUse fixes #1231 --- src/analysis.zig | 1 + tests/lsp_features/completion.zig | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/analysis.zig b/src/analysis.zig index 10fcca2..569327e 100644 --- a/src/analysis.zig +++ b/src/analysis.zig @@ -2390,6 +2390,7 @@ pub fn innermostContainer(handle: *const DocumentStore.Handle, source_index: usi } fn resolveUse(analyser: *Analyser, uses: []const Ast.Node.Index, symbol: []const u8, handle: *const DocumentStore.Handle) error{OutOfMemory}!?DeclWithHandle { + analyser.using_trail.clearRetainingCapacity(); for (uses) |index| { const gop = try analyser.using_trail.getOrPut(analyser.gpa, index); if (gop.found_existing) continue; diff --git a/tests/lsp_features/completion.zig b/tests/lsp_features/completion.zig index e31916b..5a14be6 100644 --- a/tests/lsp_features/completion.zig +++ b/tests/lsp_features/completion.zig @@ -483,6 +483,22 @@ test "completion - usingnamespace" { , &.{ .{ .label = "inner", .kind = .Function, .detail = "fn inner() void" }, }); + try testCompletion( + \\fn Bar(comptime Self: type) type { + \\ return struct { + \\ fn inner(self: Self) void { _ = self; } + \\ }; + \\} + \\const Foo = struct { + \\ pub usingnamespace Bar(Foo); + \\ fn deinit(self: Foo) void { _ = self; } + \\}; + \\const foo: Foo = undefined; + \\const bar = foo. + , &.{ + .{ .label = "inner", .kind = .Function, .detail = "fn inner(self: Self) void" }, + .{ .label = "deinit", .kind = .Function, .detail = "fn deinit(self: Foo) void" }, + }); } test "completion - block" {