lua-users home
lua-l archive

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



On 4 Jul 2006, at 17:17, Mike Pall wrote:
David Jones wrote:
Now, I don't really have an excuse for poking around in this dark
corner, but...
is this intended?

Probably not. But it's not really a bug either. It could be
called a leak in the implementation.

It's a side-effect of common code for unary and binary operators
in lvm.c and an assumption that nil never has metamethods:

  case OP_LEN:
    ...
    if (!call_binTM(L, rb, luaO_nilobject, ra, TM_LEN)) ...

This "bug" can be "fixed" be passing in rb twice.

drj

--- ../src/lvm.c        2006-01-23 19:51:43.000000000 +0000
+++ lvm.c       2006-07-05 08:15:35.000000000 +0000
@@ -519,7 +519,7 @@
           }
           default: {  /* try metamethod */
             Protect(
-              if (!call_binTM(L, rb, luaO_nilobject, ra, TM_LEN))
+              if (!call_binTM(L, rb, rb, ra, TM_LEN))
                 luaG_typeerror(L, rb, "get length of");
             )
           }