Skip to content
This repository has been archived by the owner on Jul 12, 2020. It is now read-only.

Instance properties should return new objects every time #123

Open
LPGhatguy opened this issue Oct 3, 2018 · 3 comments
Open

Instance properties should return new objects every time #123

LPGhatguy opened this issue Oct 3, 2018 · 3 comments

Comments

@LPGhatguy
Copy link
Owner

LPGhatguy commented Oct 3, 2018

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
@Kampfkarren
Copy link
Contributor

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

@LPGhatguy
Copy link
Owner Author

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.

@Kampfkarren
Copy link
Contributor

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants