lune-org / lune

A standalone Luau runtime
https://lune-org.github.io/docs
Mozilla Public License 2.0
353 stars 80 forks source link

using Instance.Parent as table keys doesnt work #242

Open AshleyFlow opened 4 weeks ago

AshleyFlow commented 4 weeks ago

Minimal repro

local roblox = require("@lune/roblox")

local obj = roblox.Instance.new("DataModel")
local child = roblox.Instance.new("ObjectValue")
child.Parent = obj

local t = {
    [obj] = 100,
}

print(t[obj]) -- 100 ✅
print(t[child.Parent]) -- nil ❌

I could just use GetFullName() instead of the instance itself, so this isnt really an issue for me, but I thought I'd make an issue for it anyway.

eAi commented 2 weeks ago

I've seen a similar issue and spent most of an evening tracking it down. Basically there seems to be situations where there are two Instance objects that reference the same underlying object in the model or place file. They are considered == to each other but rawequals returns false. I was tearing my hair out over it! It'd be really good if there was only ever one Lua object for any one object in the model/place hierarchy.