Skip to content

fix(codegen): closes #317 — wire String.matchAll codegen + NaN-box inner arrays (v0.5.415) - #331

Merged
proggeramlug merged 1 commit into
mainfrom
issue-317-string-matchall
Apr 30, 2026
Merged

fix(codegen): closes #317 — wire String.matchAll codegen + NaN-box inner arrays (v0.5.415)#331
proggeramlug merged 1 commit into
mainfrom
issue-317-string-matchall

Conversation

@proggeramlug

Copy link
Copy Markdown
Contributor

Summary

  • Adds the missing Expr::StringMatchAll codegen arm in crates/perry-codegen/src/expr.rs. Mirrors Expr::StringMatch exactly: SSO-safe receiver unbox via unbox_str_handle (same String-array element access: arr[i] SIGSEGVs and indexOf returns -1 #214 SSO bug class), regex handle via unbox_to_i64, call I64 js_string_match_all, then nanbox_pointer_inline on the resulting *mut ArrayHeader.
  • Declares js_string_match_all (I64, I64) -> I64 in runtime_decls.rs immediately after the existing js_string_match decl.
  • Fixes a latent bug in the existing crates/perry-runtime/src/regex.rs::js_string_match_all: outer-array slots holding the per-match inner array were being stored as f64::from_bits(inner_ptr as u64) (raw pointer bits). The codegen IndexGet fast paths (post-Array's hole should be undefined rather than 0 #323) expect NaN-boxed slot values, so m[1] / m[2] would have read back nonsense without this fix. Switched to js_nanbox_pointer(inner as i64) — same convention as js_array_group at array.rs:1493 and as the inner string elements.
  • New regression test test-files/test_issue_317_string_matchall.ts covers: the issue's literal repro (for...of over /([a-z]+)=([a-z]+)/g with capture group access), three-capture-group dates with full-match m[0], no-match returning empty iterable (matchAll never returns null), spread [...text.matchAll(re)] with index-into-result, and single-match.

Surfaced compiling effect/src/internal/cause.ts (func 140) during the #309 compat sweep. Companion follow-up under umbrella #321.

Test plan

  • cargo build --release -p perry-runtime -p perry-stdlib -p perry clean
  • node --experimental-strip-types test-files/test_issue_317_string_matchall.ts matches Perry binary output byte-for-byte
  • Gap tests: 27/28 = baseline (lone fail is pre-existing console_methods ci-env quirk)
  • Parity: 179/179 (100%)

Closes #317.

…ner arrays (v0.5.415)

Adds the missing Expr::StringMatchAll codegen arm (mirrors StringMatch:
SSO-safe receiver unbox, runtime call, NaN-box pointer result), declares
js_string_match_all in runtime_decls, and fixes a latent bug in the
existing js_string_match_all helper that stored inner array slots as raw
pointer bits — now NaN-boxed so for-of and indexed access through the
IndexGet path work correctly. Regression test covers iteration, capture
groups, no-match, spread, and single-match shapes.
@proggeramlug
proggeramlug merged commit 8573e54 into main Apr 30, 2026
7 of 8 checks passed
@proggeramlug
proggeramlug deleted the issue-317-string-matchall branch May 10, 2026 06:53
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.

perry-codegen Phase 2: String.matchAll codegen not implemented

1 participant