mirror of
https://github.com/kikito/inspect.lua.git
synced 2024-12-15 14:34:21 +00:00
fix overflow when a table is its own metatable. References #4
This commit is contained in:
parent
0571e63e01
commit
1514d86828
@ -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…
Reference in New Issue
Block a user