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.

2 Likes
Thanks for the report! I filed a ticket in our internal database.
1 Like
WheretIB
(WheretIB)
3
We have prepared a fix for this issue.
We will post an update after it’s released.
1 Like
When did Roblox Studio change in what order the table prints out as?
local tbl = {
["c"] = "test",
["a"] = "test"
}
print(tbl)
for k,v in pairs(tbl) do print(k,v) end
I just noticed this after running the above code for the re-production steps.
Why is Roblox Studio sorting its own print table alphabetically now?
Looks like the fix is out, is it true? And this looks to be fixed now, as the Re-production steps example now run the __tostring
I am wondering about this though.
WheretIB
(WheretIB)
6
The fix for the issue has been released.
I don’t work on Studio output, but sorting was supported since 2021.
1 Like
oh I think it’s because of the __ in my repro compared to the screenshot I took for the actual result, yeah I got confused, I think it’s fine
Very cool, thanks for the fix!
system
(system)
Closed
8
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.