Skip to content

fix Object.defineProperty sharing values across instances#1697

Merged
Perryvw merged 2 commits intoTypeScriptToLua:masterfrom
RealColdFry:fix/object-define-property-instance-isolation
Mar 28, 2026
Merged

fix Object.defineProperty sharing values across instances#1697
Perryvw merged 2 commits intoTypeScriptToLua:masterfrom
RealColdFry:fix/object-define-property-instance-isolation

Conversation

@RealColdFry
Copy link
Copy Markdown
Contributor

When Object.defineProperty is called on an instance (not a prototype), create a per-instance metatable if the shared metatable already has descriptors, so that each instance gets its own descriptor storage.

Fixes #1625

When Object.defineProperty is called on an instance (not a prototype),
create a per-instance metatable if the shared metatable already has
descriptors, so that each instance gets its own descriptor storage.

Fixes TypeScriptToLua#1625
@RealColdFry RealColdFry marked this pull request as ready for review March 27, 2026 10:19
Use a marker to always create per-instance metatables, not just when
_descriptors already exists on the shared metatable. Add more thorough
instance isolation tests.
@Perryvw Perryvw merged commit 57459c6 into TypeScriptToLua:master Mar 28, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Object.defineProperty share same value across different object instance

2 participants