Skip to content

zls doesn't infer types after 2 layers of usage?Β #2205

@MahdiGMK

Description

@MahdiGMK

Zig Version

0.14.0-dev.3367+1cc388d52

ZLS Version

0.14.0-dev.397+30b0da02

Client / Code Editor / Extensions

Zed dev 0.175.2.r93.gd0a0303 d0a0303428bed88da0c3773740a9cd8b39d8910d

Steps to Reproduce and Observed Behavior

I want to implement this wrapper function for bitset types and zls only predicts type information after 1 layer of function call.

pub fn FBS(BS: type) type {
    return struct {
        bs: BS,
        pub fn format(
            self: @This(),
            comptime fmt: []const u8,
            options: std.fmt.FormatOptions,
            writer: anytype,
        ) !void {
            _ = fmt;
            _ = options;
            _ = writer;
            std.debug.print("{}", .{self.bs.count()}); // no type-hint/auto-completion for self.bs
            // ....
        }
    };
}
pub fn fbs(bitset: anytype) FBS(@TypeOf(bitset)) {
    // auto-completion works fine here
    return FBS(@TypeOf(bitset)){ .bs = bitset };
}

Expected Behavior

Ideally zls should be able to infer that self.bs is a bitset.

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions