-
-
Notifications
You must be signed in to change notification settings - Fork 351
In a specific case the type of a value in a table can't be obtained in pairs
, but can in straight .
dot notation
#1467
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
Comments
pairs
, but can in straight "." dot notation pairs
, but can in straight .
dot notation
Just added a `local x` for the bug report. LuaLS/lua-language-server#1467
How did you declare |
Can you provide an demo project? I can't reproduce this problem. |
int is:
I will try and make a standalone complete copy of everything. As the project is loading a large number of the game's Lua code files which "may" be affecting it (I have no idea). |
I have put everything in 1 folder and it looks to still produce the issue for me. I have put every "Lua" setting from my global settings in to the workspace settings file. So the environments should be the same. The 2 files are both under |
hi, just flagging that this has the incorrect label, as I don't believe its awaiting any more information. |
Found that when I zipped up the folder it kept on removing the |
Sorry, I don’t have time to view this yet |
no worries, was more just so it was accurate for when you did get a chance :) |
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
That the type of the value of a table is obtained in both pairs and dot notation at all times.
Type of
x
and the type of xChunkObject.vs
Actual Behaviour
The "value" field in the FOR loop is unable to get the type of the value in the table, but the dot notation can.
dot notation populating the variable

x
.FOR loop failing to get the type to populate the variable

xChunkObject
.Both "know" the type of the parent

chunkDetailsByAxis
at the time of the issue,The actual warning by Sumneko is on the next line when we try to use a field of xChunkObject, as it's trying to use a field of an unknown type. But this xChunkObject is the start of the issues.
It only seems to occur for this 1
for
loop. All my other code retains it's correct types with no warnings shown.Reproduction steps
The usage of the class is in 1 file and the class is declared in another file. I shall refer to these as Usage and Declare below.
If I edit anything in the Usage file to force Sumneko to rescan then the issue goes away.
I can reproduce the issue in the Usage file by editing the Declare file so that it has an invalid Lua code syntax and then back to being valid again. i.e. removing a trailing
)
from any function in the file and then putting it back and saving the file again.The issue with reproduction is you'd need my mod (public github) and all of the libraries I add of class definitions for Factorio (public). So I can provide them if that's needed, but I appreciate it will be some messing around for you to have the same large environment.
Additional Notes
The type definitions of the these top levels of the class hierarchy are below. This should be the complete loop of self referencing classes. The other custom classes used like
int
andMapPosition
are either simple self contained classes, aliases to equally simple classes or literals.Log File
file_c%3A_Home_Projects_Factorio%20Modding_Factorio-A-Robot-Friend.log
service.log
In terms of file names of the Usage and Declare I referenced:
Declared: scan-areas-for-actions-to-complete.lua
full: file:///c%3A/Home/Projects/Factorio%20Modding/Factorio-A-Robot-Friend/scripts/tasks/scan-areas-for-actions-to-complete.lua
Usage: deconstruct-entities-in-chunk-details.lua
full: file:///c%3A/Home/Projects/Factorio%20Modding/Factorio-A-Robot-Friend/scripts/tasks/deconstruct-entities-in-chunk-details.lua
The text was updated successfully, but these errors were encountered: