Skip to content
New issue

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

Unknown global cannot be identified when using type and typeof #827

Closed
ProBaturay opened this issue Feb 2, 2023 · 1 comment · Fixed by #833
Closed

Unknown global cannot be identified when using type and typeof #827

ProBaturay opened this issue Feb 2, 2023 · 1 comment · Fixed by #833
Assignees
Labels
bug Something isn't working

Comments

@ProBaturay
Copy link

Not sure if this is intended or not, but the linter will not be able to detect the unknownGlobal or unknownGlobal2 variables without being declared both in strict and non-strict mode. This only applies when they are used in conditions using the "==" and "~=" operators.

local t : boolean = type(unknownGlobal) == "nil"
local t2 : boolean = typeof(unknownGlobal2) ~= "nil"

However, localizing the functions at the beginning of the script or typecasting the parameter with any type will resolve the issue.

local type = type
local t : boolean = type(unknownGlobal) == "nil" -- Unknown global 'unknownGlobal'
local t2 : boolean = typeof(unknownGlobal2 :: unknown) ~= "nil" -- Unknown global 'unknownGlobal2'
@ProBaturay ProBaturay added the bug Something isn't working label Feb 2, 2023
@vegorov-rbx vegorov-rbx self-assigned this Feb 6, 2023
@vegorov-rbx
Copy link
Collaborator

This wasn't intended, I'm going to work on a fix.

andyfriesen added a commit that referenced this issue Feb 10, 2023
* Fix a bug where reading a property from an unsealed table caused
inference to improperly infer the existence of that property.
* Fix #827

We have also made a lot of progress on the new solver and the JIT. Both
projects are still in the process of being built out. Neither are ready
for general use yet.

We are mostly working to tighten up how the new solver handles
refinements and updates to unsealed tables to bring it up to the same
level as the old solver.

---------

Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging a pull request may close this issue.

2 participants