lua-users home
lua-l archive

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


confirmed on linux 5.1.1
5.0.3 doesn't have this behaviour.

and turning "l=nil" into "local l=nil" also doesn't
show this behaviour.

--- Thomas Lauer <thomas.lauer@virgin.net> wrote:

> Either I am doing something so stupid that I can't
> see it or something
> fishy is going on. Consider this:
> 
> 	function x(l)
> 		z=0
> 		l=nil
> 		return l
> 	end
> 
> 	print(x("test"))
> 
> ... which prints "nil". Fine.
> 
> Now simply comment out the first line of x() (ie
> "z=0") and try again...
> this time it prints "test".
> 
> It seems that the first line of x() can be any valid
> Lua statement other
> than "l=nil" and all works fine. However, if this
> assignment is the
> first line it just doesn't work. I am puzzled.
> 
> (In case you wonder why anyone would set a function
> parameter to nil:
> the above is stripped down to the smallest code
> snippet that shows this
> behaviour. The original stuff comes from a more
> complex wrapper around a
> bunch of functions in the Lua runtime library.)
> 
> That's Lua 5.1.1 on a Win2k SP4 rollup box. I
> checked with both the
> latest precompiled binaries and a locally compiled
> version.
> 
> -- 
> cheers  thomasl
> 
> web : http://thomaslauer.com/start
> 



 
____________________________________________________________________________________
Finding fabulous fares is fun.  
Let Yahoo! FareChase search your favorite travel sites to find flight and hotel bargains.
http://farechase.yahoo.com/promo-generic-14795097