Description
This is how Userdata with __tostring
appears, when using print
on a table, where the object is put as the key.
Like so:
print({
[object_here] = "value"
})
However, tables have this skipped.
Re-production steps
- Run this in Studio
local object = newproxy(true)
getmetatable(object).__tostring = function()
return "__tostring from userdata"
end
local object2 = setmetatable({}, {
__tostring = function()
return "__tostring from table"
end,
})
print("Userdata __tostring:", object)
print("Table __tostring:", object2)
print({
[object] = "userdata test",
[object2] = "table test"
})
- Observe the Output Window
Expected Result
I expected this part
to use the corresponding __tostring
as well, but it didn’t
If __tostring
is declared on a metatable of a table, I expected the pretty print to use __tostring
.
Actual Result
__tostring
from newproxy
’s modified metatable was used. But the one from the actual table wasn’t used.