rrthomas/lua-stdlib — pull request #3 by gvvaughan (2012-02-22 13:43:42+00:00)
Title: base.lua: fix tree folding lookup on missing keys.

Since _G.fold is generic, it can't tell whether the function it
calls will try to do something illegal with the values it is
passed. So, it's possible to get a stack dump with:
$ lua -lstd
> x = tree.new ()
> return x[{1,2}]
because the second fold iteration calls `_G.op["[]"] (nil, 2)'
when there is no match from the earlier `_G.op["[]"] ({}, 1)'.
The easiest way to prevent that is in the operator function
itself.
* src/base.lua (op["[]"]): Don't try to take the index of a
non-table.