lemur icon indicating copy to clipboard operation
lemur copied to clipboard

Instance properties should return new objects every time

Open LPGhatguy opened this issue 6 years ago • 3 comments

Roblox types override __eq. This is sort of fine, but accessing properties on instances creates Lua versions of those values every time, which means they aren't rawequal and also don't hash the same! This is especially surprising for things like signals on instances that don't ever change.

This was a Lemur difference that caused a real bug in Roact. Basically:

local signalMap = {}
local part = Instance.new("Part")

signalMap[part.Changed] = "foo"

print(signalMap[part.Changed]) -- "foo" in Lemur, nil in Roblox

LPGhatguy avatar Oct 03 '18 21:10 LPGhatguy

How do you expect the code for this to be written without a major overhaul?

Kampfkarren avatar Oct 04 '18 03:10 Kampfkarren

No idea. Maybe this is a problem that stays mostly unsolved, since it's an edge of Roblox that I'm sure is subject to randomly change.

LPGhatguy avatar Oct 04 '18 06:10 LPGhatguy

Yeah I'm a bit hesitant about replicating undocumented behavior as well, especially on something that'd need a code overhaul like this.

Kampfkarren avatar Oct 04 '18 13:10 Kampfkarren