PlutoLang / Pluto

A superset of Lua 5.4 with a focus on general-purpose programming.
https://pluto-lang.org/docs/Introduction
MIT License
337 stars 20 forks source link

Switch statement parsing confusion #853

Closed XmiliaH closed 1 month ago

XmiliaH commented 1 month ago

The switch parser sometimes uses parts of the case value and also includes it in the case body.

local tab = {
    print=function(...) print("TabPrint", ...) end
}
switch 1 do
    case 2: break
    case true?1:tab:
        print("OK")
end

In this case the tab: is in the case value, but the skip over the case will end at 1: and so tab: is also included in the switch case body.