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

🐛 Incorrect inferred type for variable declaration #2166

Open
vegerot opened this issue Feb 3, 2025 · 1 comment
Open

🐛 Incorrect inferred type for variable declaration #2166

vegerot opened this issue Feb 3, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@vegerot
Copy link

vegerot commented Feb 3, 2025

Zig Version

0.13.0

ZLS Version

0.13.0

Client / Code Editor / Extensions

NVIM v0.11.0-dev-1664+ge71d2c817d / nvim-lspconfig

Steps to Reproduce and Observed Behavior

zls incorrectly says the type of const arr = .{ "1", "22" }; is [2]*const [1:0]u8 when it's actually struct{comptime *const [1:0]u8 = "1", comptime *const [2:0]u8 = &.{ 50, 50 }}

Image
const std = @import("std");
pub fn main() void {
    const arr = .{ "1", "22" };
    std.debug.print("type of arr: {}\n", .{@TypeOf(arr)});
}

If I were to put zls' inferred type here, then it'd be

    const arr: [2]*const [1:0]u8 = .{ "1", "22" }; // expected type '*const [1:0]u8', found '*const [2:0]u8'

Expected Behavior

My main issue is the inlay type

Image

imo the way this hint is displayed, the expectation should be that changing the hint into real code should work.

@vegerot vegerot added the bug Something isn't working label Feb 3, 2025
@xdBronch
Copy link
Contributor

xdBronch commented Feb 4, 2025

this looks like #2065

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