Skip to content

test262: RegExp conformance fixes (wave 11) - #67

Merged
hiett merged 1 commit into
experiment/js-frontendfrom
js262/wave11-RegExp
Jul 15, 2026
Merged

test262: RegExp conformance fixes (wave 11)#67
hiett merged 1 commit into
experiment/js-frontendfrom
js262/wave11-RegExp

Conversation

@hiett

@hiett hiett commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Routes the RegExp well-known-symbol methods on a RegExp receiver through the JS frontend: re[Symbol.match](s), re[Symbol.replace](s, r), re[Symbol.search](s), re[Symbol.split](s, lim).

Previously a computed-key call whose key was one of these symbols was lowered as an ordinary property read (undefined), so every such call crashed with {badfun,undefined}. Each method is the receiver-swapped twin of the matching String.prototype method (indeed String.prototype.match(re) is defined as invoking re[Symbol.match](s)), so they route to the same runtime op with the string as receiver and the regex as the pattern argument, reusing the existing global/sticky lastIndex handling.

Spec: ECMAScript §22.2.6.8 (@@match), §22.2.6.11 (@@replace), §22.2.6.12 (@@search), §22.2.6.14 (@@split).

test262 test/built-ins/RegExp/prototype: pass 78 → 115 (runtime_error 96 → 41). New spec-driven tests appended to js_compiler_test.gleam. No FFI or shared-helper changes.

Wire the well-known-symbol methods on a RegExp receiver — re[Symbol.match](s),
re[Symbol.replace](s, r), re[Symbol.search](s), re[Symbol.split](s, lim) — through
the frontend. A computed-key call whose key is one of these symbols was previously
lowered as an ordinary property read (undefined), so every such call crashed with
{badfun,undefined}.

Each method is the receiver-swapped twin of the matching String.prototype method
(String.prototype.match(re) is itself defined as invoking re[Symbol.match](s)), so
they route to the identical runtime op with the string as receiver and the regex as
the pattern argument, reusing the existing global/sticky lastIndex handling.
Covers §22.2.6.8/.11/.12/.14.
@hiett
hiett merged commit af4ba73 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