gvvaughan/lua-stdlib — comment on commit 3ad23d35da00356c6770272660022cee47f18cae
File:  line 0
By gvvaughan:

Hmmm... then again, tree's __index is not involved at the point of failure:

```
┌─┤gary@thoth│~/Devo/lua-stdlib--rrthomas--0/src >*?│origin│378879d
├!11942│^3=git diff origin | cat
diff --git a/src/base.lua b/src/base.lua
index ee5b614..c5435a1 100644
--- a/src/base.lua
+++ b/src/base.lua
@@ -478,6 +478,7 @@ end
-- FIXME: Make these visible in LuaDoc (also list.concat in list)
_G.op["[]"] =
function (t, s)
+ print (tostring(t), type(t), tostring(getmetatable(t)))
return t[s]
end
┌─┤gary@thoth│~/Devo/lua-stdlib--rrthomas--0/src >*?│origin│378879d
├!11943│^3=LUA_PATH='./?.lua;;' LUA_CPATH= lua -lstd
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
> x=tree.new()
> =x[{1,2}]
{} table {__index=function: 0x7ffd6a41fb90,__newindex=function: 0x7ffd6a420240}
nil nil nil
./base.lua:482: attempt to index local 't' (a nil value)
stack traceback:
./base.lua:482: in function 'f'
./base.lua:432: in function <./base.lua:429>
(tail call): ?
(tail call): ?
stdin:1: in main chunk
[C]: ?
```

Maybe all we're left with is a better guard in _G.op?

```lua
_G.op["[]"] = function (t, s)
local mm = getmetatable (t) and getmetatable (t).__index
if type (t) == "table" or mm then
return t[s]
else
return t
end
end
```

WDYT?