clear using_trail when calling resolveUse

fixes #1231
This commit is contained in:
Techatrix 2023-06-09 23:13:36 +02:00
parent 1020817ed0
commit 77e39a8da8
2 changed files with 17 additions and 0 deletions

View File

@ -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 { 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| { for (uses) |index| {
const gop = try analyser.using_trail.getOrPut(analyser.gpa, index); const gop = try analyser.using_trail.getOrPut(analyser.gpa, index);
if (gop.found_existing) continue; if (gop.found_existing) continue;

View File

@ -483,6 +483,22 @@ test "completion - usingnamespace" {
, &.{ , &.{
.{ .label = "inner", .kind = .Function, .detail = "fn inner() void" }, .{ .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.<cursor>
, &.{
.{ .label = "inner", .kind = .Function, .detail = "fn inner(self: Self) void" },
.{ .label = "deinit", .kind = .Function, .detail = "fn deinit(self: Foo) void" },
});
} }
test "completion - block" { test "completion - block" {