Skip to content

feat(engine): implement Iterator.prototype.join proposal - #5503

Merged
jedel1043 merged 2 commits into
boa-dev:mainfrom
xcb3d:feat/iterator-prototype-join
Sep 1, 2026
Merged

feat(engine): implement Iterator.prototype.join proposal#5503
jedel1043 merged 2 commits into
boa-dev:mainfrom
xcb3d:feat/iterator-prototype-join

Conversation

@xcb3d

@xcb3d xcb3d commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

This Pull Request implements the Stage 3 TC39 proposal Iterator.prototype.join.

It changes the following:

  • Implement %IteratorPrototype%.join(separator) under the experimental feature flag in core/engine/src/builtins/iterable/iterator_prototype.rs.
  • Follow the TC39 specification semantics:
    • Validates that the receiver is an Object (TypeError otherwise).
    • Coerces the separator to a String before accessing the iterator's next method.
    • Correctly calls IfAbruptCloseIterator if separator coercion or element string conversion fails.
    • Treats null and undefined elements as empty strings.
  • Add comprehensive unit tests in core/engine/src/builtins/iterable/tests.rs.
  • Remove "Iterator.prototype.join" from the ignored list in test262_config.toml.
  • All 18 test262 tests in test/built-ins/Iterator/prototype/join/ now pass (100% Conformance).

@xcb3d
xcb3d requested a review from a team as a code owner August 31, 2026 16:59
@github-actions github-actions Bot added the Waiting On Review Waiting on reviews from the maintainers label Aug 31, 2026
@github-actions github-actions Bot added this to the v0.23 milestone Aug 31, 2026
@github-actions github-actions Bot added C-Tests Issues and PRs related to the tests. C-Builtins PRs and Issues related to builtins/intrinsics labels Aug 31, 2026
@github-actions

github-actions Bot commented Aug 31, 2026

Copy link
Copy Markdown

Test262 conformance changes

Test result main count PR count difference
Total 53,578 53,578 0
Passed 51,408 51,426 +18
Ignored 1,666 1,648 -18
Failed 504 504 0
Panics 0 0 0
Conformance 95.95% 95.98% +0.03%
Fixed tests (18):
test/built-ins/Iterator/prototype/join/results-empty-separator.js (previously Ignored)
test/built-ins/Iterator/prototype/join/receiver-not-object.js (previously Ignored)
test/built-ins/Iterator/prototype/join/contents-nullish.js (previously Ignored)
test/built-ins/Iterator/prototype/join/descriptor.js (previously Ignored)
test/built-ins/Iterator/prototype/join/not-a-constructor.js (previously Ignored)
test/built-ins/Iterator/prototype/join/next-lookup-after-separator-tostring.js (previously Ignored)
test/built-ins/Iterator/prototype/join/results-nonempty-separator.js (previously Ignored)
test/built-ins/Iterator/prototype/join/closes-on-separator-coercion-exception.js (previously Ignored)
test/built-ins/Iterator/prototype/join/does-not-close-on-iterator-exhaustion.js (previously Ignored)
test/built-ins/Iterator/prototype/join/does-not-close-on-next-getter-error.js (previously Ignored)
test/built-ins/Iterator/prototype/join/results-no-separator.js (previously Ignored)
test/built-ins/Iterator/prototype/join/does-not-close-on-iterator-error.js (previously Ignored)
test/built-ins/Iterator/prototype/join/name.js (previously Ignored)
test/built-ins/Iterator/prototype/join/separator-tostring.js (previously Ignored)
test/built-ins/Iterator/prototype/join/length.js (previously Ignored)
test/built-ins/Iterator/prototype/join/does-not-close-on-iterator-protocol-violation.js (previously Ignored)
test/built-ins/Iterator/prototype/join/contents-tostring.js (previously Ignored)
test/built-ins/Iterator/prototype/join/closes-on-contents-coercion-exception.js (previously Ignored)

Tested main commit: 8665669463872b475404f5316eb221767c7b10d1
Tested PR commit: 5b4b8499b35f0f7263928313d6054a1dccbea5ca
Compare commits: 8665669...5b4b849

@codecov

codecov Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.94%. Comparing base (6ddc2b4) to head (5b4b849).
⚠️ Report is 1049 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #5503       +/-   ##
===========================================
+ Coverage   47.24%   62.94%   +15.69%     
===========================================
  Files         476      536       +60     
  Lines       46892    60286    +13394     
===========================================
+ Hits        22154    37945    +15791     
+ Misses      24738    22341     -2397     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jedel1043 jedel1043 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for the contribution! Implementation wise looks great, I just have a small suggestion to simplify a bit of code.

Comment on lines +552 to +585
// 6. Let R be the empty String.
// 7. Let first be true.
let mut r = Vec::new();
let mut first = true;

// 8. Repeat,
while let Some(value) = iterated.step_value(context)? {
// a. Let value be ? IteratorStepValue(iterated).
// b. If value is done, return R.
// c. If first is true, set first to false.
// d. Else, set R to the string-concatenation of R and sep.
if first {
first = false;
} else {
r.push(sep.clone());
}

// e. If value is neither undefined nor null, then
if !value.is_null_or_undefined() {
// i. Let S be Completion(ToString(value)).
// ii. ? IfAbruptCloseIterator(S, iterated).
// iii. Set R to the string-concatenation of R and S.
let s = value.to_string(context);
let s = if_abrupt_close_iterator!(s, iterated, context);
r.push(s);
}
}

// 9. Return R.
if r.is_empty() {
return Ok(js_string!().into());
}

let strs: Vec<_> = r.iter().map(crate::JsString::as_str).collect();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This might be a good place to start using our new CommonJsStringBuilder API, which is nice for building JsStrings in a nicer way.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review @jedel1043! I've updated the implementation to use CommonJsStringBuilder as suggested.

@xcb3d
xcb3d requested a review from jedel1043 September 1, 2026 07:27

@jedel1043 jedel1043 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks great, thank you!

@jedel1043
jedel1043 added this pull request to the merge queue Sep 1, 2026
Merged via the queue into boa-dev:main with commit 665f039 Sep 1, 2026
22 checks passed
@github-actions github-actions Bot removed the Waiting On Review Waiting on reviews from the maintainers label Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-Builtins PRs and Issues related to builtins/intrinsics C-Tests Issues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants