We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create a file with the following code:
---@alias MyArray<T> table<number,T> ---@generic Y ---@param arg MyArray<Y> local function f(arg) end ---@type MyArray<string> local arg = {"foobar"} f(arg)
Error on line f(arg): Type mismatch. Required: 'MyArray<number>' Found: 'MyArray<string>'
f(arg)
Type mismatch. Required: 'MyArray<number>' Found: 'MyArray<string>'
No error: this is a valid call to f(). The generic Y type should be inferred as string, but for some reasons Luanalysis tries to infer it as number.
f()
Y
string
number
None
The problem is related to aliases. Luanalysis properly infer the generic Y if f is declared as follows:
f
---@generic Y ---@param arg table<number,Y> local function f(arg) end
The text was updated successfully, but these errors were encountered:
eb53cb5
No branches or pull requests
Environment
Preferences
Lua
Type Safety
What are the steps to reproduce this issue?
Create a file with the following code:
What happens?
Error on line
f(arg)
:Type mismatch. Required: 'MyArray<number>' Found: 'MyArray<string>'
What were you expecting to happen?
No error: this is a valid call to
f()
. The genericY
type should be inferred asstring
, but for some reasons Luanalysis tries to infer it asnumber
.Any logs, error output, etc?
None
Any other comments?
The problem is related to aliases. Luanalysis properly infer the generic
Y
iff
is declared as follows:The text was updated successfully, but these errors were encountered: