[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua 5.4: question about label visibility rule
- From: Arnaud Delobelle <arnodel@...>
- Date: Wed, 19 Jan 2022 15:27:45 +0000
Hi Roberto,
On Wed, 19 Jan 2022 at 14:58, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
>
> > In the Lua 5.4 docs it says the following.
> >
(**)
> > A label should not be declared where a label with the same
> > name is visible, even if this other label has been declared
> > in an enclosing block.
> >
> > I have found the following test in the Lua 5.4.3 Test Suite (available
> > here: http://www.lua.org/tests/), in the file goto.lua (starting line
> > 223):
> >
> > [...]
> >
> > In this function the label ::l1:: is declared twice, once in the
> > "elseif a == 4" clause and once at the end of the function. In my
> > understanding, the second declaration of this label is visible at the
> > point where the first declaration is made. That would contravene the
> > rule I have quoted above.
> >
> > This must mean that I am misunderstanding the meaning of the quoted
> > rule. Could anyone please help me understand it?
>
> REMEMBER: "The test suite is not a product; it is just a tool for our
> internal use." (Third paragraph in http://www.lua.org/tests/)
Yes I understand that. Still my current understanding is that either
there is a bug in Lua 5.4.3 (and its test suite) or I do not
understand the exact meaning of the rule that I quote above (**). To
make things clearer, here are two minimal examples.
---- error.lua ----
do
::foo::
do
-- Outer label 'foo' is visible from here, so I expect an error
::foo::
end
end
---- end ----
The 'error.lua' file produces the error:
lua: error.lua:5: label 'foo' already defined on line 2
---- success.lua ----
do
do
-- Outer label 'foo' is visible from here, so I expect an error
::foo::
end
::foo::
end
---- end ----
I would expect a similar error as above but the 'success.lua' file
successfully runs under Lua 5.4.3. I hope these examples make my
query clearer.
Regards,
--
Arnaud