test262: String conformance fixes (wave 11) - #68
Merged
Conversation
String.prototype.split (§22.1.3.21) begins with S = ToString(this). A
new String(...) wrapper object was reaching binary:split/2 as a cell and
crashing with badarg. Unwrap a {js_wrapper, string, Prim} receiver to its
boxed primitive so new String("a-b").split("-") matches the primitive.
charAt, charCodeAt, codePointAt, toUpperCase and toLowerCase begin with
S = ToString(this) (§22.1.3). A new String(x) wrapper object reached
cps/string:uppercase as a cell and crashed with badarg. Unwrap the
{js_wrapper, string, Prim} receiver via str_this so a wrapper behaves
identically to the string primitive.
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.
Two focused, spec-driven fixes to String.prototype method dispatch on primitive-wrapper receivers.
Fixes
1. split coerces a String-wrapper receiver
String.prototype.split(§22.1.3.21) begins withS = ToString(RequireObjectCoercible(this)). Anew String(x)wrapper object was reachingbinary:split/2as a cell and crashing with badarg. Added a String-family helperstr_this/1that unwraps a{js_wrapper, string, Prim}cell to its boxed primitive; plain strings pass through unchanged.2. char/index/case methods coerce a String-wrapper receiver
charAt,charCodeAt,codePointAt,toUpperCase,toLowerCaseare each spec'dS = ToString(this)(§22.1.3) and had the same wrapper-receiver badarg. Routed them throughstr_this.Impact (test/built-ins/String/prototype)
No shared helpers modified (
str_thisis a new String-local helper; the sharedto_string/cpsare only called, never changed). erlc -Wall clean, gleam build warning-free, gleam format clean, js_compiler_test green (only the 3 pre-existing WASM .wat fixture failures remain).