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

This commit is contained in:
kikito 2013-01-20 17:23:36 +01:00
parent 0571e63e01
commit 1514d86828
2 changed files with 10 additions and 1 deletions

View File

@ -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

View File

@ -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)