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'm wondering why arr1 (using alias) and arr2 (using parenthesis) work differently. I expected to have completion and error checking for A array elements in arr2 the same way I get them in arr1. In other words, I should get assign-type-mismatch diagnostic when trying to set x to 'string' in arr2, and also for trying to have a number element (3) in an array of string|A.
Actual Behaviour
I don't get any completion suggestions or diagnostics while setting the value for the arr2 case (union of multiple types).
However, if I use arr2 later I do get type checking and completion:
fork, vinipairs(arr2) dov.x=1-- v is correctly inferred as string|Aendlocalv=arr2[2] -- v is correctly inferred as string|Aarr2[3].x='hi' -- assign-type-mismatch
so the language server does understand (string|A)[] syntax in certain cases.
Reproduction steps
Try the code sample I posted.
Additional Notes
I can just use aliases, but sometimes I only need these union types for a parameter or a single location, and an alias introduces a new name globally.
Log File
No response
The text was updated successfully, but these errors were encountered:
How are you using the lua-language-server?
Visual Studio Code Extension (sumneko.lua)
Which OS are you using?
Windows
What is the issue affecting?
Annotations, Type Checking, Completion
Expected Behaviour
In the following example:
I'm wondering why
arr1
(using alias) andarr2
(using parenthesis) work differently. I expected to have completion and error checking forA
array elements inarr2
the same way I get them inarr1
. In other words, I should getassign-type-mismatch
diagnostic when trying to setx
to'string'
inarr2
, and also for trying to have a number element (3
) in an array ofstring|A
.Actual Behaviour
I don't get any completion suggestions or diagnostics while setting the value for the
arr2
case (union of multiple types).However, if I use
arr2
later I do get type checking and completion:so the language server does understand
(string|A)[]
syntax in certain cases.Reproduction steps
Try the code sample I posted.
Additional Notes
I can just use aliases, but sometimes I only need these union types for a parameter or a single location, and an alias introduces a new name globally.
Log File
No response
The text was updated successfully, but these errors were encountered: