You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think I got to the root of this. The cause is caching of the node types (link to code). The cache does not take into account the fact that the return type depends on the arguments to the function.
Another observation: the reason why hover works most of the time is because the Analyser is instantiated for each request (with clean cache). So this bug can happen on hover as well, if the same Declaration needs to be evaluated multiple times within the single hover resolution.
fnarr(comptimeT: anytype) []T {
return &[_]T{};
}
// The deeper `arr` is evaluated, the outer `arr` is from cache// should be [][]u1, but both hint and hover is []u1pubconsthover=arr(@TypeOf(arr(u1)));
Zig Version
0.12.0-dev.3439+31a7f22b8
Zig Language Server Version
0.12.0-dev.496+96eddd0
Client / Code Editor / Extensions
VSCode with official extension
Steps to Reproduce and Observed Behavior
Put this code into a file
You'll see ZLS incorrectly show the type of
two
as[]u16
This behaviour gets very weird when its spread across multiple functions
https://github.com/zigtools/zls/assets/34501060/c0f9498b-a24e-403b-921e-b026b93a516c
Expected Behavior
The type of all the alloc calls is correctly resolved
Relevant log output
No response
The text was updated successfully, but these errors were encountered: