boa icon indicating copy to clipboard operation
boa copied to clipboard

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

Open amrkhaled104 opened this issue 9 months ago • 1 comments

Describe the bug I found a bug in how String.prototype.split works in Boa. According to the ECMAScript spec, when we use split(separator), the engine should only check for Symbol.split if the separator is an Object Right now, Boa tries to access Symbol.split even if the separator is a primitive (like 1n, true, or 100). This is wrong because if someone adds a custom function to BigInt.prototype[Symbol.split], Boa will call it, but the spec says it should ignore it for primitives.

To Reproduce You can also see this by running the official Test262 test:

cargo run --bin boa_tester -- run -s "test/built-ins/String/prototype/split/cstm-split-on-bigint-primitive.js"

Expected behavior

Boa should check if the separator is an Object. Since 1n is a primitive, it should skip the Symbol.split check, convert 1n to the string "1", and return ["a", "b"]

Actual behavior tries to access Symbol.split on the primitive, triggers the error, and the test fails.

[spec]: According to Section 22.1.3.21, step 2, the engine should only look for @@split if the separator is an Object.

Test Evidence: Full Suite Failure: As seen in the screenshot below, there are 4 failing tests in the split directory, resulting in 96.67% conformance.

Image

Specific Test Failure: Specifically, the test cstm-split-on-bigint-primitive.js fails with an F as shown here: Image

amrkhaled104 avatar Feb 22 '26 00:02 amrkhaled104

@jedel1043 I have already fixed this issue and verifiedThe String.prototype.split conformance is now at 100% (120/120). I will submit a Pull Request (PR) shortly, please take a look

amrkhaled104 avatar Feb 22 '26 00:02 amrkhaled104