Support optional chaining
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?
Formatting
Expected Behaviour
if weaps[i]?.serial ~= tempInv[i].vars.serial then
if weaps[i]?.obj then
DeleteObject(weaps[i].obj)
weaps[i] = nil
end
GiveWeap(tempInv[i])
end
Actual Behaviour
syntax Problem '?'
Reproduction steps
- Go to '...'
- Click '...'
- See error '...'
Additional Notes
No response
Log File
No response
Are you trying to do optional chaining? As far as I know, that is not a feature in Lua. You would have to do something more like:
if weaps[i] and weaps[i].serial ~= tempInv[i].vars.serial then
This is indeed optional chaining in LUA . For example in FiveM if you develop there in LUA it allows for optional chaining. Some extra LUA lib adds this feature to this. So I would be nice to have an option where you can allow for optional chaining to be a thing.
Interesting! Do you have a link to documentation of the feature? I tried looking for more info on their documentation website but the search managed to allocate over 1GB of RAM and slam my CPU 😆

I haven't found wich lib or how they changed it. LUA description here they are talking about a modified 5.3 lua called cfxlua but haven't seen whats under the hood.
Maybe it's this one? https://github.com/citizenfx/lua/blob/luaglm-dev/cfx/README.md#safe-navigation
Adding all these features means that it's no longer Lua, so it seems like a better idea to fork the Language server specifically for that variant. It looks like that's what cfxlua-vscode is doing.
See https://github.com/LuaLS/lua-language-server/wiki/Plugins
Ok didn't know somebody already made a plugin for all those libs. Awesome.
Maybe it would be good to support a form of this through a snippet like how ++? works right now