zls icon indicating copy to clipboard operation
zls copied to clipboard

Enum/Union function completions missing inside slices of that type.

Open MaximilianHeidenreich opened this issue 6 months ago • 0 comments

Zig Version

0.14.1

ZLS Version

0.14.0

Client / Code Editor / Extensions

NVIM v0.11.2

Steps to Reproduce and Observed Behavior

Create an enum or union with member functions:

const TestEnum = enum(u8) {
  .foo,
  .bar
  
  pub fn baz() TestEnum {
    return .bar;
  }
};

const TestUnion = union(enum) {
  .foo,
  .bar: u8,

  pub fn baz(num: u8) TestUnion {
    return .{ .bar = num };
  }
};

Now, given a function which takes a slice of thes enum/union, it won't display any LSP completions when inside the slice:

pub fn exampleUnions(comptime items: []const TestUnion) void {
  _ = items;
  return;
}

pub fn exampleEnums(comptime items: []const TestEnum) void {
  _ = items;
  return;
}

pub fn main() !void {
  const testUnion = exampleUnions(&.{ . });
  //                                   ^ Start typing ".", there should be completions for .foo, .bar, .baz()
  //                                     but it doesn't display anything!

  const testEnum = exampleEnums(&.{ . });
  //                                 ^ Start typing ".", there should be completions for .foo, .bar, .baz()
  //                                   but it doesn't display anything!
}

Expected Behavior

It should display the field/function completion hints:

  • .foo
  • .bar
  • .baz(): TestUnion

Relevant log output


MaximilianHeidenreich avatar Jul 08 '25 12:07 MaximilianHeidenreich