zls icon indicating copy to clipboard operation
zls copied to clipboard

Struct initialization completions broken for struct defined in nested struct

Open Jarred-Sumner opened this issue 2 years ago • 2 comments

Zig Version

0.12.0-dev.899+027aabf49

Zig Language Server Version

1a282b30cccb6dd52438fa1ef6e6b887069e109f

Steps to Reproduce

  1. Paste the following code:
pub const bar = struct {
    pub const baz = struct {
        pub const Foo = struct {
            a: u32 = 0,
        };

        pub fn qux() u32 {
            return Foo{
                .
            };
        }
    };
};
test {
    bar.baz.qux() == 0;
}
  1. No completions for a image

Note that if Foo is moved to be defined inside bar instead of baz, it works as expected.

Expected Behavior

Completions for the Foo struct fields should work

Actual Behavior

No completions for the struct fields

Jarred-Sumner avatar Oct 15 '23 02:10 Jarred-Sumner

Notes:

  • Known (parser) limitation.
  • Workaround: Do digit dot as if this is a float number, eg 1.

llogick avatar Oct 15 '23 03:10 llogick

This appears to be fixed by https://github.com/zigtools/zls/pull/1536.

Techatrix avatar Oct 31 '23 19:10 Techatrix