lua-users home
lua-l archive

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

Adam D. Moss wrote:
Asko Kauppi wrote:

It's deep down in the code, but this is what catches it:

    local n= table.getn(tbl)

    if (n>0 and (not tbl[n])) then  -- BUG TRAPPING in Lua5.1w1 !!!
        print( "TWN:", n, tbl.n )
        error "TRAPPED!"

TWN:    2       nil

I'm pretty sure (as was mentioned some time in the past) that
the 'n' index no longer literally exists in the table (thank
goodness!).  getn/setn now keep the table->'n' mapping somewhere
private (or not-so-private -- perhaps the registry -- but at
least this stops tables being implicitly polluted with 'n').

Oh, sorry, I misread your code a bit.  What I mentioned would
explain the 2,nil thing but perhaps not the (n>0 and (not tbl[n]))
thing (unless tbl[n] was boolean false).