lua-users home
lua-l archive

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

I am quite surprised that the following code crashes Lua-5.1.2 and
Lua-5.1.3 (luajit)

> print( table.concat({[1]=1, [2]=2, [4]=4}, '/') )

stdin:1: bad argument #1 to 'concat' (table contains non-strings)
stack traceback:
        [C]: in function 'concat'
        stdin:1: in main chunk
        [C]: ?

The table above has a single hole (missing t[3]). Official reference
manual is silent about this case. Is it a bug?

On the other hand, why does the following code works

> print( table.concat({[1]=1, [3]=3,  [5]=4}, '/') )

The last example also has 2 holes (t[2],t[4]) but it works. Go figure:-)