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
Prevent TplRefs from escaping into types of global variables
If a global variable is not annotated, and there's an assignment to it
in a generic function, there's a chance that references to generic parameters
will end up in its type.
This commit fixes the situation by skipping a type from a particular assignment
if it contains generic references.
This is a rather simplistic implementation. We could be smarter about it:
it's possible to analyze generics that're referenced from a type and replace
them with their bounds:
```lua
--- @Generic T: Bound
--- @param x T
function foo(x)
-- After this commit, `globalVar` will have type `undefined` in other files;
-- instead, we can infer it as `Bound`.
globalVar = x
end
```
However, this will require saving bounds to a global context,
and lazily replacing them later. I've decided to leave it as is for now.
0 commit comments