Merge pull request #1232 from Techatrix/usingnamespace-invalid-usingtrail

clear using_trail when calling resolveUse
This commit is contained in:
Lee Cannon 2023-06-09 23:18:07 +01:00 committed by GitHub
commit e1e75a1e63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 {
analyser.using_trail.clearRetainingCapacity();
for (uses) |index| {
const gop = try analyser.using_trail.getOrPut(analyser.gpa, index);
if (gop.found_existing) continue;

View File

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