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 expect the type of p to be integer|string and the call get_val('hi') to work without any warnings.
Actual Behaviour
I get a param-type-mismatch problem in the call get_val('hi'):
Cannot assign string to parameter integer.\n- string cannot match integer\n- Type string cannot match integer
Hovering over p in the function definition function get_val(p) I see the type as integer.
This happens when type() is assigned to a local variable. If I remove the local variable and change the function body to return type(p) == 'number' and p or p then everything works as expected.
Reproduction steps
Try the code above in VS Code with the latest version of the extension. Let me know if you need more information or logs.
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?
Type Checking
Expected Behaviour
Consider the following simplified example:
I expect the type of p to be
integer|string
and the callget_val('hi')
to work without any warnings.Actual Behaviour
I get a
param-type-mismatch
problem in the callget_val('hi')
:Hovering over
p
in the function definitionfunction get_val(p)
I see the type asinteger
.This happens when
type()
is assigned to a local variable. If I remove the local variable and change the function body toreturn type(p) == 'number' and p or p
then everything works as expected.Reproduction steps
Try the code above in VS Code with the latest version of the extension. Let me know if you need more information or logs.
Additional Notes
Probably a more general case of #1841
Log File
No response
The text was updated successfully, but these errors were encountered: