How are you using the lua-language-server?
Other
Which OS are you using?
Linux
What is the issue affecting?
Type Checking
Expected Behaviour
Using the nil-coalescing operator should narrow an expressions type. For example, in this sample code, the type of b should be narrowed to integer:
---@type integer?
local foo = 1
local bar = foo ?? 2
Actual Behaviour
Instead of the type being narrowed, the type of foo is copied instead, and the type of bar is thought to be integer? instead of integer.
Reproduction steps
- Insert the following sample code in a project:
---@type integer?
local foo = 1
local bar = foo ?? 2
- Check the type of
b
Additional Notes
This seems to work fine using the classic Lua approach with or:
---@type integer?
local foo = 1
local bar = foo or 2
The type of bar is integer here, as expected.
Log File
No response
How are you using the lua-language-server?
Other
Which OS are you using?
Linux
What is the issue affecting?
Type Checking
Expected Behaviour
Using the nil-coalescing operator should narrow an expressions type. For example, in this sample code, the type of
bshould be narrowed tointeger:Actual Behaviour
Instead of the type being narrowed, the type of
foois copied instead, and the type ofbaris thought to beinteger?instead ofinteger.Reproduction steps
bAdditional Notes
This seems to work fine using the classic Lua approach with
or:The type of
barisintegerhere, as expected.Log File
No response