fix overflow when a table is its own metatable. References #4

eLua
kikito 12 years ago
parent 0571e63e01
commit 1514d86828
  1. 2
      inspect.lua
  2. 9
      spec/inspect_spec.lua

@ -110,10 +110,10 @@ function Inspector:countTableAppearances(t)
self:countTableAppearances(k) self:countTableAppearances(k)
self:countTableAppearances(v) self:countTableAppearances(v)
end end
self:countTableAppearances(getmetatable(t))
else else
self.tableAppearances[t] = self.tableAppearances[t] + 1 self.tableAppearances[t] = self.tableAppearances[t] + 1
end end
self:countTableAppearances(getmetatable(t))
end end
end end

@ -191,6 +191,15 @@ describe( 'inspect', function()
} }
}]]) }]])
end) end)
it('accepts a table that is its own metatable without stack overflowing', function()
local x = {}
setmetatable(x,x)
assert.equals(inspect(x), [[<1>{
<metatable> = <table 1>
}]])
end)
end) end)
end) end)
end) end)

Loading…
Cancel
Save