Kinda confused about type inference on struct literals passed to associated functions. #2239
WERTBON1789
started this conversation in
General
Replies: 1 comment
-
I believe that this a bug in ZLS's code completions for anonymous struct literal. It failing to resolve an expression that chains a function call like |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I'm kinda new to Zig therefor also to ZLS.
I have this weird behavior I wanted to get behind:
I pass an anonymous struct literal as the File.OpenFlags arguments, as I think it can be done, it also compiles just fine, it just seems ZLS has no idea that this struct has that type, the comment is what I wanted to get as completion, but in this case I just got nothing, neither a false error, nor any suggestions.
After some experimenting I got it to work like this:
It seems like ZLS can't cope with the Dir returned from cwd directly but has to have it in a separate variable?
It kinda confused me a bit.
I think the more "correct" code would be something like this anyways:
But I found it kinda weird that it just wouldn't work.
Zig: 0.15.0-dev.151+6e8493daa
ZLS: 0.15.0-dev.31+99eaaf61
Editor is Neovim, if that's maybe relevant.
Beta Was this translation helpful? Give feedback.
All reactions