mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-08 05:27:14 +09:00
LibJS: Disable optimization in IteratorNextUnpack if next() is redefined
81b6a11
regressed correctness by always bypassing the `next()` method
resolution for built-in iterators, causing incorrect behavior when
`next()` was redefined on built-in prototypes. This change fixes the
issue by storing a flag on built-in prototypes indicating whether
`next()` has ever been redefined.
This commit is contained in:
parent
a6d9e8acd8
commit
f405d71657
Notes:
github-actions[bot]
2025-05-12 11:42:25 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: f405d71657
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4700
18 changed files with 151 additions and 8 deletions
|
@ -1769,7 +1769,7 @@ class PropertyNameIterator final
|
|||
public:
|
||||
virtual ~PropertyNameIterator() override = default;
|
||||
|
||||
BuiltinIterator* as_builtin_iterator() override { return this; }
|
||||
BuiltinIterator* as_builtin_iterator_if_next_is_not_redefined() override { return this; }
|
||||
ThrowCompletionOr<void> next(VM&, bool& done, Value& value) override
|
||||
{
|
||||
while (true) {
|
||||
|
@ -3175,7 +3175,7 @@ ThrowCompletionOr<void> IteratorNextUnpack::execute_impl(Bytecode::Interpreter&
|
|||
|
||||
Value value;
|
||||
bool done = false;
|
||||
if (auto* builtin_iterator = iterator_record.iterator->as_builtin_iterator()) {
|
||||
if (auto* builtin_iterator = iterator_record.iterator->as_builtin_iterator_if_next_is_not_redefined()) {
|
||||
TRY(builtin_iterator->next(vm, done, value));
|
||||
} else {
|
||||
auto result = TRY(iterator_next(vm, iterator_record));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue