[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Goto and return ('end' expected)
- From: Dirk Laurie <dirk.laurie@...>
- Date: Wed, 6 May 2015 13:56:27 +0200
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.