zls icon indicating copy to clipboard operation
zls copied to clipboard

treat constant functions as functions

Open orvitpng opened this issue 2 years ago • 2 comments

Let's use the following example code:

pub const Writer = struct {
    write: fn (bytes: []const u8) usize,
    pub fn write_all(self: *Writer, bytes: []const u8) void {
        var i = 0;
        while (i < bytes.len) {
            i += self.write(bytes);
        }
    }
};

When using the language server, if you try to reference the write function, it will not be treated as a function as it is considered a value. However, by all intensive purposes, it is a function. For this reason, I motion that these be treated as functions by the language server.

I understand that it may be important to have a distinction between an actual function and a constant function, however, this will enhance the experience of actually using them and remove confusion.

orvitpng avatar Nov 06 '23 19:11 orvitpng

related issue #423

Techatrix avatar Nov 06 '23 19:11 Techatrix

imo it should not because the color it gets helps you differentiate whether its a field or a decl. they operate in different namespaces and are allowed to shadow/conflict so long as the reference is unambiguous

nektro avatar Nov 06 '23 21:11 nektro