Skip to content

avm2: Fix with-scope to use [[HasProperty]] - #25106

Open
MooderSan wants to merge 4 commits into
ruffle-rs:masterfrom
MooderSan:fix/avm2-with-scope-has-property
Open

MooderSan wants to merge 4 commits into
ruffle-rs:masterfrom
MooderSan:fix/avm2-with-scope-has-property

Conversation

@MooderSan

@MooderSan MooderSan commented Nov 5, 2026 •

Copy link
Copy Markdown

Description

This PR fixes a bug in AVM2 with-statement scoping that manifests as TypeError: Error #1006: value is not a function in SWFs compiled with asc.jar that use E4X filter expressions containing method calls, e.g. someXML.(name() == x).

Per the AVM2 specification, with (obj) resolves unqualified names by calling [[HasProperty]] on obj — that is, it walks the full prototype chain, matching ECMAScript semantics for with. Ruffle 0.7.1 only checked [[HasOwnProperty]] in ScopeChain::find and search_scope_stack. As a result, names defined on a prototype (for example XML.prototype.name) were not found for objects brought into scope by with.

Changes are limited to core/src/avm2/scope.rs:

ScopeChain::find — for with-scopes, use has_property (walks the prototype chain) instead of has_own_property. Non-object values fall back to has_own_property to preserve existing behavior for pathological with-scopes.

search_scope_stack — same change, via the renamed helper.

Rename value_has_own_property → value_has_property; for Value::Object, call object.has_property(multiname).

TObject::has_property already walks the prototype chain, so no changes were needed in object.rs or in activation.rs.

Testing

asc.jar inlines E4X filter expressions into the following bytecode (abridged):

text
pushwith
findpropstrict name
callproperty name, 0
...
popscope
With obj being an XML node, name lives on XML.prototype, not on the node itself. findpropstrict name returned undefined, and the following callproperty name, 0 threw #1006.

We observed this in the wild on embedded equipment running a Flash-based control/management UI. The device's gui.swf (v2.4.42, built with asc.jar) embeds a navigator page (com.tvips.prodbase.pages.SubidNavigatorPage) that traverses an XML tree using . (name() == overviewnodename) inside updateTreeExpansion().

Under Ruffle 0.7.1 the navigator failed to populate and the page was unusable — no entries appeared, and the sin URL parameter was sent as null instead of the selected sub-identifier. The same SWF runs without issues on Adobe Flash Player, confirming this is a Ruffle-side deviation from the AVM2 spec rather than a bug in the SWF. After the fix, XML.name() is invoked normally, the navigator renders correctly, and sin becomes a valid identifier.

Checklist

  • I, a human, have self-reviewed this PR and fully understand the changes within.
  • I have made or updated tests where possible.
  • All of my commits are properly scoped, compile successfully, and pass all tests.
  • This PR does not make sense to split up into smaller PRs.
  • An LLM was involved in the authoring of this code.

@MartySVK

MartySVK commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Please use the pull request description template.

@danielhjacobs

Copy link
Copy Markdown
Contributor

That is not the pull request description template. Please edit your original comment to use the pull request description template (see below):

Description

Testing

Checklist

  • I, a human, have self-reviewed this PR and fully understand the changes within.
  • I have made or updated tests where possible.
  • All of my commits are properly scoped, compile successfully, and pass all tests.
  • This PR does not make sense to split up into smaller PRs.
  • An LLM was involved in the authoring of this code.

@danielhjacobs danielhjacobs added A-avm2 Area: AVM2 (ActionScript 3) waiting-on-author Waiting on the PR author to make the requested changes T-fix Type: Bug fix (in something that's supposed to work already) llm The PR contains mostly LLM-generated code labels Nov 5, 2026
@danielhjacobs danielhjacobs added squash-on-merge Marks a PR to be squashed before merging. and removed waiting-on-author Waiting on the PR author to make the requested changes labels Nov 6, 2026
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) llm The PR contains mostly LLM-generated code squash-on-merge Marks a PR to be squashed before merging. 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