mirror of
https://github.com/TangentFoxy/inspect.lua.git
synced 2025-07-28 11:02:18 +00:00
fix overflow when a table is its own metatable. References #4
This commit is contained in:
@@ -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)
|
||||||
|
Reference in New Issue
Block a user