[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: weird behaviour of table.sort
- From: Wolfgang Pupp <wolfgang.pupp@...>
- Date: Mon, 28 Jun 2010 19:41:52 +0200
If table.sort is called with an invalid comparison function, the
comparison function may get a (quite unexpected) 'nil' as argument.
Consider this code:
local function lesser(a, b)
assert(a and b)
The assertion fails- only if you remove it, you'll the expected
'invalid order function for sorting'- error.
IMHO, it would be desirable to change this behaviour, that is, if a
table does not contain nil- elements, the comparison function should
never get nil as argument, either.
I observed this with LuaJIT (beta-4) and Lua-5.1.4 (at least I think
so; I'm never quite sure where windows loads it's DLL's from, so one
implementation could be unaffected).