Skip to content

fix(string): ensure separator is an object before calling Symbol.split#4664

Open
amrkhaled104 wants to merge 3 commits intoboa-dev:mainfrom
amrkhaled104:fix-string-split-primitive
Open

fix(string): ensure separator is an object before calling Symbol.split#4664
amrkhaled104 wants to merge 3 commits intoboa-dev:mainfrom
amrkhaled104:fix-string-split-primitive

Conversation

@amrkhaled104
Copy link
Contributor

@amrkhaled104 amrkhaled104 commented Feb 22, 2026

This Pull Request fixes #4663

Changes:

  • Added a check to ensure the separator is an Object before looking for the @@split method.
  • This prevents the engine from calling custom split functions added to primitive prototypes (like BigInt.prototype).
  • Updated the logic in core/engine/src/builtins/string/mod.rs

Validation:

  • I ran the official Test262 suite for String.prototype.split.
  • Before fix: 116/120 tests passed (4 failed).
  • After fix: 120/120 tests passed (100% conformance).

Test Results Screenshot:
image
I have expanded the fix to include other string methods that were also incorrectly accessing Symbol methods on primitive separators.

@github-actions
Copy link

github-actions bot commented Feb 22, 2026

Test262 conformance changes

Test result main count PR count difference
Total 52,862 52,862 0
Passed 49,472 49,487 +15
Ignored 2,249 2,249 0
Failed 1,141 1,126 -15
Panics 0 0 0
Conformance 93.59% 93.62% +0.03%
Fixed tests (15):
test/built-ins/String/prototype/matchAll/cstm-matchall-on-bigint-primitive.js (previously Failed)
test/built-ins/String/prototype/matchAll/cstm-matchall-on-number-primitive.js (previously Failed)
test/built-ins/String/prototype/matchAll/cstm-matchall-on-string-primitive.js (previously Failed)
test/built-ins/String/prototype/search/cstm-search-on-bigint-primitive.js (previously Failed)
test/built-ins/String/prototype/search/cstm-search-on-number-primitive.js (previously Failed)
test/built-ins/String/prototype/search/cstm-search-on-boolean-primitive.js (previously Failed)
test/built-ins/String/prototype/search/cstm-search-on-string-primitive.js (previously Failed)
test/built-ins/String/prototype/match/cstm-matcher-on-bigint-primitive.js (previously Failed)
test/built-ins/String/prototype/match/cstm-matcher-on-boolean-primitive.js (previously Failed)
test/built-ins/String/prototype/match/cstm-matcher-on-number-primitive.js (previously Failed)
test/built-ins/String/prototype/match/cstm-matcher-on-string-primitive.js (previously Failed)
test/built-ins/String/prototype/split/cstm-split-on-boolean-primitive.js (previously Failed)
test/built-ins/String/prototype/split/cstm-split-on-bigint-primitive.js (previously Failed)
test/built-ins/String/prototype/split/cstm-split-on-number-primitive.js (previously Failed)
test/built-ins/String/prototype/split/cstm-split-on-string-primitive.js (previously Failed)

if let Some(splitter) = splitter {
// i. Return ? Call(splitter, separator, « O, limit »).
return splitter.call(separator, &[this.clone(), limit.clone()], context);
if let Some(separator_obj) = separator.as_object() {
Copy link
Member

@jedel1043 jedel1043 Feb 25, 2026

Choose a reason for hiding this comment

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

Kind of unrelated, but now that you're touching this part of the code, can you change this to use let chains and &&s?
Something like if !separator.blah() && let Some(separator_obj) = blah

Also kind of applies to the rest of the added lines since I see that a lot of them are just two nested ifs.

@jedel1043 jedel1043 added bug Something isn't working builtins PRs and Issues related to builtins/intrinsics labels Feb 25, 2026
@jedel1043 jedel1043 added this to the v1.0.0 milestone Feb 25, 2026
@jedel1043 jedel1043 added the waiting-on-author Waiting on PR changes from the author label Feb 25, 2026
@codecov
Copy link

codecov bot commented Feb 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.63%. Comparing base (6ddc2b4) to head (83c102f).
⚠️ Report is 678 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4664      +/-   ##
==========================================
+ Coverage   47.24%   56.63%   +9.39%     
==========================================
  Files         476      548      +72     
  Lines       46892    60011   +13119     
==========================================
+ Hits        22154    33990   +11836     
- Misses      24738    26021    +1283     

☔ View full report in Codecov by Sentry.
📢 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working builtins PRs and Issues related to builtins/intrinsics waiting-on-author Waiting on PR changes from the author

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: String.prototype.split should not access Symbol.split on primitive separators

2 participants