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(v)
end
self:countTableAppearances(getmetatable(t))
else
self.tableAppearances[t] = self.tableAppearances[t] + 1
end
self:countTableAppearances(getmetatable(t))
end
end

@ -191,6 +191,15 @@ describe( 'inspect', function()
}
}]])
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)

Loading…
Cancel
Save