zls
zls copied to clipboard
🐛 Incorrect inferred type for variable declaration
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 }}
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
imo the way this hint is displayed, the expectation should be that changing the hint into real code should work.
this looks like https://github.com/zigtools/zls/issues/2065
The inlay hint now displays struct{ *const [1:0]u8, *const [2:0]u8 }.