If clause overwrites number
like class type on variable
#1679
Labels
Info Needed
More information is required
number
like class type on variable
#1679
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
I wouldn't expect doing an
if
check on a variable to change its type.I am using this with the Factorio game API which includes a lot of number or integer like types for subsets of these. I have included an example typedef for one of these.
In 3.5.x this code wasn't warned about, but in 3.6.1 it is.
Actual Behaviour
The type of my variables are being overwritten by the type that they are compared to in an
if
statement. The work around I found was to type all of these comparison values, but it feels a bit clunky.Reproduction steps
The same occurs with just a locally defined variable that has its type and value set as type
ASmallNumber
. When comparing with an equivilentif
the explicitly defined type is overridden.Additional Notes
Fuller local variable example:
Log File
No response
The text was updated successfully, but these errors were encountered: