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

Annotations are incorrect #1897

Closed
akhildevelops opened this issue May 20, 2024 · 5 comments
Closed

Annotations are incorrect #1897

akhildevelops opened this issue May 20, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@akhildevelops
Copy link

Zig Version

0.12.0

Zig Language Server Version

0.12.0

Client / Code Editor / Extensions

VsCode

Steps to Reproduce and Observed Behavior

image

I've declared an arraylist containing slice of u8 slices.
var splits = std.ArrayList([][]const u8).init(allocator);

While iterating I get wrong annotation but the hover gives correct type info, as seen in the above image

Expected Behavior

Both should be consistent

Relevant log output

No response

@akhildevelops akhildevelops added the bug Something isn't working label May 20, 2024
@Techatrix
Copy link
Member

The following code snippet resolves item as [][]const u8. Could you post the entire code snippet?

const std = @import("std");
test {
    const splits = std.ArrayList([][]const u8).init(undefined);
    for (splits.items) |item| {
        _ = item;
    }
}

I suspect this to be related to #1392.

@akhildevelops
Copy link
Author

For me i's still incorrect.

image

Zig - 0.12.0
ZLS- 0.12.0
Zig VsCode Extension- 0.5.7
VSCode - 1.89.1

@Techatrix
Copy link
Member

For me i's still incorrect.

I can't reproduce this with Zig 0.12.0 and ZLS 0.12.0.

You could you post ZLS's log output? (VSCode: Bottom Panel -> Output -> Zig Language Server)

@akhildevelops
Copy link
Author

akhildevelops commented May 22, 2024

kazam_qfoenyyr.movie.webm

I got the issue, type annotations are wrong when there's for loop iteration before it. You can see in the video.

Here's the code for easy copy paste.

const std = @import("std");

const Fpp = struct {
    tokens: std.ArrayList([][]const u8),
    const Self = @This();
    pub fn free(self: *Self) void {
        for (self.tokens.items) |token| {
            _ = token;
        }
        self.tokens.deinit();
    }

    test {
        const splits = std.ArrayList([][]const u8).init(undefined);
        for (splits.items) |item| {
            _ = item;
        }
    }
};

test {
    const splits = std.ArrayList([][]const u8).init(undefined);
    for (splits.items) |item| {
        _ = item;
    }
}

ZLS logs are clean

info : ( main ): Starting ZLS 0.12.0 @ '/home/akhil/.config/Code/User/globalStorage/ziglang.vscode-zig/zls_install/zls'
info : (server): Client is 'Visual Studio Code-1.89.1'
info : (server): No config file zls.json found. This is not an error.
info : (server): Set config option 'global_cache_path' to '/home/akhil/.cache/zls'
info : (server): Set config option 'semantic_tokens' to 'partial'
info : (server): Set config option 'builtin_path' to '/home/akhil/.cache/zls/builtin.zig'
info : (server): Set config option 'zig_lib_path' to '/home/akhil/.config/Code/User/globalStorage/ziglang.vscode-zig/zig_install/lib'
info : (server): Set config option 'zig_exe_path' to '/home/akhil/.config/Code/User/globalStorage/ziglang.vscode-zig/zig_install/zig'
info : (server): Set config option 'build_runner_path' to '/home/akhil/.cache/zls/build_runner_0.12.0.zig'
info : (server): Set config option 'build_runner_global_cache_path' to '/home/akhil/.cache/zig'

@Techatrix
Copy link
Member

This is the same underlying issue as #1841

@Techatrix Techatrix closed this as not planned Won't fix, can't repro, duplicate, stale May 22, 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