Solarus Forum

Solarus => Development => Topic started by: Zefk on October 10, 2016, 06:56:30 am

Title: Tip: Control structure too long near
Post by: Zefk on October 10, 2016, 06:56:30 am
This can happen with too many if statements  are nested into one if statement.

Code: [Select]
Control structure too long near
Too many elseif statements in one if control structure can cause the same error.

Code: ( lua) [Select]
if X then
   -- stuff
elseif Y then
   -- stuff
elseif Z then
   -- stuff
end

Source:
https://forums.wowace.com/showthread.php?t=21768

It can happen with a loop too.

Code: ( lua) [Select]
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

Source:
http://lua.2524044.n2.nabble.com/Cause-for-quot-control-structure-too-long-quot-td7650425.html
Title: Re: Tip: Control structure too long near
Post by: Christopho on October 10, 2016, 09:27:58 am
If you reach this kind of limit, there is something really wrong with your code.
Title: Re: Tip: Control structure too long near
Post by: Zefk on October 10, 2016, 11:28:26 am
I fixed it, so nothing is wrong with my script.