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
This shows no warnings and does not require me to pass any arguments to cool(), which is incorrect. Hovering over cool provides a type of 'TestFunction' and does not show the full expanded type of the alias, unlike other variables with a type of an alias. That rings the same with this code sample I also tested:
where hovering over abc provides me with a 'TestFunction' unexpanded type.
However, correct behavior is seen with the following code sample using the base string type;
Autocomplete is provided for :find() and abc.cool = "hi" throws the correct warning for field injection.
And most confusing of all, this code sample behaves in line with expected behavior, and the alias is fully expanded.
---@aliasTestFunctionfun(abc: string): integer---@genericT---@paramname`T`---@paramfuncfun(cool: T)---@returnTlocalfunctiontestSecond(name, func) endlocalcool=testSecond("TestFunction",
---@paramabcTestFunctionfunction(abc)
abc()
end
)
This also doesn't work, which I kind of expected. (no warnings)
Reproduction steps
Paste code into project with Lua LSP on, see issue
Additional Notes
No response
Log File
No response
The text was updated successfully, but these errors were encountered:
I checked another test case with a class instead of an alias. It seems like generic capture parameters flat out don't work in anything other than an @return; they won't work with successive @parameters trying to use the generic type. They show in VSCode as the correct type (see the ---@param func fun(cool: T) example) but don't actually narrow to the type in question.
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
With a code sample like this:
I would expect
abc
to have a type ofstring
, and the function to be type checked and require a return.Actual Behaviour
Instead,
abc
has theany
type and the function requires no return.I further tested with a different code sample:
This shows no warnings and does not require me to pass any arguments to
cool()
, which is incorrect. Hovering overcool
provides a type of 'TestFunction' and does not show the full expanded type of the alias, unlike other variables with a type of an alias. That rings the same with this code sample I also tested:where hovering over
abc
provides me with a 'TestFunction' unexpanded type.However, correct behavior is seen with the following code sample using the base
string
type;Autocomplete is provided for :find() and
abc.cool = "hi"
throws the correct warning for field injection.And most confusing of all, this code sample behaves in line with expected behavior, and the alias is fully expanded.
This also doesn't work, which I kind of expected. (no warnings)
Reproduction steps
Additional Notes
No response
Log File
No response
The text was updated successfully, but these errors were encountered: