lua-users home
lua-l archive

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


In message <42479.1024065042@zoonami.com>, David Jones writes:
> In my lua 4.0 the following code crashes (with a floating point
> exception):
> 
> a={}
> a[2^31+1]=1

Further investigation reveals that getn uses a similar conversion and
can crash in the same way.

(While I was looking at getn I noticed)
There is a bug in the documentation for getn.  The documentation says:

... the largest numerical index with a non-nil value in the table

but the following code prints 0:

print(getn{[-9]="foo"})

So the documentation should say:

This number is the value of the table field n, if it has a numeric
value, or the largest positive numerical index with a non-nil value
in the table, or 0 if no such index exists.

Cheers,
 drj