Re: luajit and goto

  • From: Peter Cawley <corsix@xxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Wed, 18 Dec 2013 00:40:21 +0000

On Wed, Dec 18, 2013 at 12:31 AM, David Given <david.given@xxxxxxxxx> wrote:
> This is actually forbidden in stock Lua --- you're not allowed to jump
> into the scope of a variable. LuaJIT fails with an error, but my copy of
> Lua 5.2 seems to allow it, which it shouldn't. (It then fails the
> assertion later.) I think stock Lua is wrong here.

The following three excepts from the 5.2 reference manual would seem
to make the particular example valid:

1. A goto may jump to any visible label as long as it does not enter
into the scope of a local variable.
2. The scope of a local variable begins at the first statement after
its declaration and lasts until the last non-void statement of the
innermost block that includes the declaration.
3. Labels and empty statements are called void statements, as they
perform no actions.

Other related posts: