-
-
Notifications
You must be signed in to change notification settings - Fork 561
Description
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.
Specific Test Failure: Specifically, the test cstm-split-on-bigint-primitive.js fails with an F as shown here:
