Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZLS intellisense suggests duplicate declarations in complex namespace types #1891

Closed
mbartelsm opened this issue May 9, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@mbartelsm
Copy link

mbartelsm commented May 9, 2024

Zig Version

0.12.0

Zig Language Server Version

0.12.0

Client / Code Editor / Extensions

VSCode with Zig extension

Steps to Reproduce and Observed Behavior

The following code

const S = struct {
    pub fn foo() void {}
};

const S1 = struct {
    pub const a: i32 = 0;
};

const S2 = struct {
    pub const a: u8 = 0;
};

fn S3(comptime opt: bool) type {
    return if (opt) struct {
        pub usingnamespace S;
        pub usingnamespace S1;
    }
    else struct {
        pub usingnamespace S;
        pub usingnamespace S2;
    };
}

pub fn main() !void {
    _ = S3(true). // <<< Autocomplete here
}

Will produce duplicate suggestions.

image

If you use more complex branching, every possibility will be added, resulting in even more duplicates

image

Expected Behavior

I would expect duplicates to be filtered out.

By a duplicate I mean a declaration of matching name and type. I believe there is merit in keeping declarations of matching name but different type as, barring more sophisticated type evaluation, an overview of all the available types is better than a single wrong one.

Alternatively, "unknown" or the most general type (i32 and u8 => Int, or fn () void and fn (bool) !Bar => Fn) could be specified instead

Relevant log output

No response

@mbartelsm mbartelsm added the bug Something isn't working label May 9, 2024
@mbartelsm mbartelsm changed the title ZLS intellisense suggests duplicate declarations for complex types ZLS intellisense suggests duplicate declarations in complex namespace types May 9, 2024
@Techatrix
Copy link
Member

Duplicate of #1041

@Techatrix Techatrix marked this as a duplicate of #1041 May 25, 2024
@Techatrix Techatrix closed this as not planned Won't fix, can't repro, duplicate, stale May 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants