lua-users home
lua-l archive

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


On Tue, Jan 29, 2013 at 11:00 PM, Petite Abeille
<petite.abeille@gmail.com> wrote:
Interesting - first TestGlobal.lua passes with 5.1 (at least with
master), and gives the false results with 5.2

> do
>   local _ENV = {}
>   _NAME = 'BAZ'
>   function Foo() if _NAME then return end end
>   function Bar() Foo() end
> end
> lglob: TestGlobal.lua:9: undefined get _NAME
> lglob: TestGlobal.lua:10: undefined get Foo
>
>

With 5.1, we get

lglob: env1.lua:3: undefined set _NAME
lglob: env1.lua:4: undefined set Foo
lglob: env1.lua:4: undefined get _NAME
lglob: env1.lua:5: undefined set Bar
lglob: env1.lua:5: undefined get Foo

which is what I expect; with '-g' (allow globals to be defined) it
passes without remarks.

It's another subtle difference between 5.1 and 5.2 encoding getting us
here.  (BTW, _ENV is not treated specially yet for 5.2)

Static analysis of dynamic languages starts out optimistically like
Napoleon invadiing Russia in the Summer, and then gets bogged down in
the Winter ;)

steve d.