lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


2015-05-06 13:47 GMT+02:00 Aapo Talvensaari <aapo.talvensaari@gmail.com>:
> Any reason for why this is not valid Lua code:
>
> for i=1,10 do
>     if i < 10 then
>         goto nxt
>     end
>     return "done"
>     ::nxt::
> end
>
> (Error: lua: a.lua:6: 'end' expected (to close 'for' at line 1) near '::')

Syntax says:

   block ::= {stat} [retstat]

I.e. an return statement must be the last statement
in a block. A label is a statement.