Cause for "control structure too long"

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Cause for "control structure too long"

Wizzy
I've been using Lua since a few years now and someone asked me to solve an error for him
"control structure too long", I looked it up via Google and the source code but couldn't really determine why it pops up.

All I know is that it comes from
static void fixjump (FuncState *fs, int pc, int dest)
if some offset it too big.

Can anyone give me an explanation of the error?
Reply | Threaded
Open this post in threaded view
|

Re: Cause for "control structure too long"

Luiz Henrique de Figueiredo
"control structure too long" occurs for instance in a loop whose body
is too big so that the jump back to the loop (or to its end) cannot be
represented in the corresponding VM instruction. See the test program below:

local b="x=1;"
while true do
        local s="while true do "..b.." end"
        local f,err=loadstring(s)
        print(#b)
        if f==nil then
                print(#b,err)
                break
        end
        b=b..b
end