Skip to content

Fix different priority of getter if by name or property on different namespaces#23253

Open
wsxarcher wants to merge 6 commits intoruffle-rs:masterfrom
wsxarcher:fix_property_priority
Open

Fix different priority of getter if by name or property on different namespaces#23253
wsxarcher wants to merge 6 commits intoruffle-rs:masterfrom
wsxarcher:fix_property_priority

Conversation

@wsxarcher
Copy link
Copy Markdown
Contributor

@wsxarcher wsxarcher commented Mar 15, 2026

When a subclass declares a field with the same local name as a private (or internal) field in a superclass, AVM2 property lookups via bracket access (this["field"]) were resolving to the wrong slot.

The priority is reversed from where they are present in the set with priority to publics.

Traced with Flashplayer 32

@Lord-McSweeney
Copy link
Copy Markdown
Collaborator

Lord-McSweeney commented Mar 16, 2026

Unfortunately I think the proper solution to this is a little more complicated. We need to change our vtable implementation so that each vtable first attempts to lookup a property on only its own map, then falls back to its parent vtable. See this SWF: chainedvt.swf.zip

It outputs

subclass-field1
subclass-field1
superclass-field2
superclass-field2

with this PR, but

subclass-field1
subclass-field1
subclass-field2
subclass-field2

with FP.

Since Subclass's vtable is the top-most, in FP the property lookups all find properties on it, which means none of the property lookups get a chance to look at Superclass's vtable.

@wsxarcher
Copy link
Copy Markdown
Contributor Author

Fixing the insertion order rather than the lookup seems to fix also your case without touching the vtable, I added your test.

@danielhjacobs danielhjacobs added A-avm2 Area: AVM2 (ActionScript 3) T-fix Type: Bug fix (in something that's supposed to work already) labels Mar 16, 2026
@wsxarcher wsxarcher force-pushed the fix_property_priority branch from 010c017 to 3f8de16 Compare March 25, 2026 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-avm2 Area: AVM2 (ActionScript 3) T-fix Type: Bug fix (in something that's supposed to work already)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants