zls icon indicating copy to clipboard operation
zls copied to clipboard

Hover not working on try in circle brackets

Open StringNick opened this issue 2 years ago • 1 comments

Zig Version

0.12.0-dev.2543+9eda6ccef

Zig Language Server Version

0.12.0-dev.371+47373c1

Client / Code Editor / Extensions

vscode

Steps to Reproduce and Observed Behavior

(try somefunc()) <- do not understand type, so hover not working (i suppose) working hover:

image

not working hover:

image

Expected Behavior

expect to work hover as on first screenshot

Relevant log output

const std = @import("std");

const SomeTypeB = struct {
    b: u8 = 0,

    pub fn get_b(self: SomeTypeB) u8 {
        return self.b;
    }
};

const SomeType = struct {
    a: SomeTypeB = undefined,

    pub fn get_a(self: SomeType) !SomeTypeB {
        return self.a;
    }
};

pub fn main() !void {
    const a = SomeType{
        .a = SomeTypeB{ .b = 1 },
    };

    const b = try a.get_a();
    // b get_b func hover is working
    const b_val = b.get_b();

    // get_b func hover is not working, but code is right
    const b_val_2 = (try a.get_a()).get_b();

    try std.testing.expect(b_val == b_val_2);
}

StringNick avatar Feb 07 '24 00:02 StringNick

There is a completion test that is the same as this issue: https://github.com/zigtools/zls/blob/0eb76c584ce6cb6eff0eaddb819ee186f8721df0/tests/lsp_features/completion.zig#L1430-L1438

Techatrix avatar Feb 07 '24 01:02 Techatrix