Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 3 additions & 26 deletions interpreter/runtime/property.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -959,32 +959,9 @@ fn Interpreter::get_computed_property_impl(
}
}
}
_ => ()
}
// Handle Symbol.iterator default for arrays
let iterator_sym = well_known_symbols.iterator
if sym.id == iterator_sym.id {
let (override_getter, override_value) = get_array_iterator_override(
arr,
well_known_symbols~,
)
match override_getter {
Some(getter) => return self.call_value(getter, obj, [], loc)
None => ()
}
match override_value {
Some(v) => return v
None => ()
}
// Return default array iterator
return make_method_func(
name="[Symbol.iterator]",
length=0,
realm_state=Some(realm_state),
fn(_this_val, _args) {
realm_state.make_array_iterator_value(arr)
},
)
Null | Undefined => ()
proto_val =>
return self.get_computed_property(proto_val, Symbol(sym), loc)
}
return Undefined

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Continue symbol lookup through array prototype overrides

When an array's prototype override is another array or a Proxy, get_array_prototype returns Array(...)/Proxy(...), so this return Undefined is now reached because the preceding walk only handles Object(proto_data). After deleting the fallback, cases like Object.setPrototypeOf(a, []); a[Symbol.iterator] or Object.setPrototypeOf(a, new Proxy(Array.prototype, {})); for (const x of a) {} lose the inherited Array.prototype iterator and throw, even though OrdinaryGet should keep walking through those prototype objects; route this path through the existing symbol-prototype walker or handle non-Object prototypes before returning.

Useful? React with 👍 / 👎.

}
Expand Down