Skip to content

test262: String conformance fixes (wave 11) - #68

Merged
hiett merged 2 commits into
experiment/js-frontendfrom
js262/wave11-String
Jul 15, 2026
Merged

test262: String conformance fixes (wave 11)#68
hiett merged 2 commits into
experiment/js-frontendfrom
js262/wave11-String

Conversation

@hiett

@hiett hiett commented Jul 15, 2026

Copy link
Copy Markdown
Owner

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 with S = ToString(RequireObjectCoercible(this)). A new String(x) wrapper object was reaching binary:split/2 as a cell and crashing with badarg. Added a String-family helper str_this/1 that 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, toLowerCase are each spec'd S = ToString(this) (§22.1.3) and had the same wrapper-receiver badarg. Routed them through str_this.

Impact (test/built-ins/String/prototype)

  • pass 236 -> 265 (+29)
  • runtime_error 151 -> 126
  • fail_assert 40 -> 36

No shared helpers modified (str_this is a new String-local helper; the shared to_string/cps are 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).

hiett added 2 commits July 15, 2026 04:37
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.
@hiett
hiett merged commit fb3dcd3 into experiment/js-frontend Jul 15, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant