When using an empty list [] (or empty table {}) as a pattern in a switch/when clause, YueScript generates invalid Lua code that attempts to destructure into an empty table literal, which causes a syntax error in Lua.
Code example:
switch x
when [] then []
else x
Generated lua
local _exp_0 = x
local _type_0 = type(_exp_0)
local _tab_0 = "table" == _type_0 or "userdata" == _type_0
local _match_0 = false
if _tab_0 then
{ } = _exp_0 -- Syntax error here
_match_0 = true
return { }
end
if not _match_0 then
return x
end
Environment:
$ yue --version
Yuescript version: 0.33.9