Fix IteratorClose omission in IteratorRecord (IteratorStep / IteratorStepValue)#5245
Closed
mrhapile wants to merge 1 commit intoboa-dev:mainfrom
Closed
Fix IteratorClose omission in IteratorRecord (IteratorStep / IteratorStepValue)#5245mrhapile wants to merge 1 commit intoboa-dev:mainfrom
mrhapile wants to merge 1 commit intoboa-dev:mainfrom
Conversation
Implement IfAbruptCloseIterator semantics for: - IteratorRecord::step - IteratorRecord::step_value Ensure iterator.close() is invoked when accessing `done` or `value` throws, while preserving the original error per ECMA-262. Improves spec compliance and iterator safety. Signed-off-by: mrhapile <allinonegaming3456@gmail.com>
Test262 conformance changes
Broken tests (12):Tested main commit: |
Contributor
Author
Contributor
Author
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5245 +/- ##
===========================================
+ Coverage 47.24% 59.87% +12.63%
===========================================
Files 476 582 +106
Lines 46892 63469 +16577
===========================================
+ Hits 22154 38002 +15848
- Misses 24738 25467 +729 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Member
|
Printing You can also compare with node <<EOF
let closed = false;
let iter = {
next() {
return {
get done() {
throw new Error("boom");
},
};
},
return() {
closed = true;
return {};
},
};
try {
iter.next();
} catch {}
console.log(closed); // should be true
EOF
false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Fix IteratorClose omission in IteratorRecord (IteratorStep / IteratorStepValue)
Background
ECMA-262 requires that iterators are properly closed when an abrupt completion occurs during iteration.
Specifically:
Both require the use of IfAbruptCloseIterator, which ensures that the iterator’s
returnmethod is invoked if accessing:done(IteratorComplete)value(IteratorValue)throws an exception.
Problem
The current implementation of:
IteratorRecord::stepIteratorRecord::step_valuepropagates errors using
?without invokingIteratorClose, which can leave iterators in an unclosed state when:donegetter throwsvaluegetter throwsThis violates ECMAScript semantics and may lead to incorrect iterator behavior.
Changes
?with explicit error handling in both methodsiterator.close(Err(err.clone()), context)drop(...)Example Scenario