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
---@type string[] | nil local strs = {"abc"} if strs ~= nil then print(strs[1]) end
Error: No such indexer '[1] found on type 'nil'
No error.
I'm not sure if it's intentional or not, but I think it should report error in this case. For example, in C#, if we do manual null check first:
private string? _str = null; ... if(_str != null) { _str.ToUpper(); }
It'll compile without problem.
Furthermore, what's the alternative? Put --[[---@not nil]] everywhere?
--[[---@not nil]]
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Environment
Preferences
Lua
Type Safety
What are the steps to reproduce this issue?
What happens?
Error: No such indexer '[1] found on type 'nil'
What were you expecting to happen?
No error.
Any other comments?
I'm not sure if it's intentional or not, but I think it should report error in this case. For example, in C#, if we do manual null check first:
It'll compile without problem.
Furthermore, what's the alternative? Put
--[[---@not nil]]
everywhere?The text was updated successfully, but these errors were encountered: