zls icon indicating copy to clipboard operation
zls copied to clipboard

Confusing inlay hints with arrays of unknown types

Open vadim-za opened this issue 1 year ago • 0 comments

Zig Version

0.12.0

Zig Language Server Version

0.12.0

Client / Code Editor / Extensions

VS Code 1.86.1 (Windows), extension: Zig Language v0.5.7

Steps to Reproduce and Observed Behavior

Enter the following code in the editor:

pub fn main() void {
    const v = SomeType{};
    const a = [2]SomeType{ .{}, .{} };
}

Observed inlay hints (underscores are used to mark the inlay hints in the code):

    const v = SomeType{};
    const a __: [2](unknown type)__ = [2]SomeType{ .{}, .{} };

Expected Behavior

  • The inlay hints for the v and a constants are inconsistent to each other. Expected either both inlay hints be present or both be absent (preferably absent, as suggested in https://github.com/zigtools/zls/issues/1526).
  • More importantly, the inlay hint for the a constant, if any, is expected to display [2]SomeType rather than [2](unknown type), as the type is directly available from the RHS of the = sign. Same holds for the inlay hint for v.

Apparently, the whole issue can become obsolete if https://github.com/zigtools/zls/issues/1526 is implemented, reporting just in case.

Relevant log output

No response

vadim-za avatar May 04 '24 11:05 vadim-za