-
-
Notifications
You must be signed in to change notification settings - Fork 331
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
Type warning when calling os.time with a table #2475
Comments
Interesting, I can't reproduce this issue. |
I can reproduce it. It's because of the fix for this issue: #2235
|
I also narrowed it down to that commit. Maybe @carsakiller can tell us why the |
It didn't work because of the introduction of the missing field diagnostic. |
@firas-assaad is correct. It was necessary to prevent excessive nil checking. This seems to be a similar problem, unfortunately. I'm not sure if there is anything we can do with just the definitions to fix the string issue, as the return types of If we add local tDate = os.date("*t", os.time())
---@cast tDate -string
local newTime = os.time(tDate) |
I'm fine with having to cast to remove the string type. The current logic makes sense: a function may return a string, so if you pass the value to another function that only accepts tables, you'll have to add annotations to express your intent. Now it'd be nice if we could override function definitions to say that the more specific |
That is the problem talked about pretty extensively in #1456. |
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
No warning
Actual Behaviour
The following warning is appearing:
Cannot assign
string|osdate
to parameterosdateparam?
.string
cannot matchosdateparam?
string
cannot matchnil
string
cannot matchosdateparam
Reproduction steps
Additional Notes
No response
Log File
No response
The text was updated successfully, but these errors were encountered: