fix(codegen): closes #317 — wire String.matchAll codegen + NaN-box inner arrays (v0.5.415) - #331
Merged
Merged
Conversation
…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.
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.
Summary
Expr::StringMatchAllcodegen arm incrates/perry-codegen/src/expr.rs. MirrorsExpr::StringMatchexactly: SSO-safe receiver unbox viaunbox_str_handle(same String-array element access: arr[i] SIGSEGVs and indexOf returns -1 #214 SSO bug class), regex handle viaunbox_to_i64,call I64 js_string_match_all, thennanbox_pointer_inlineon the resulting*mut ArrayHeader.js_string_match_all (I64, I64) -> I64inruntime_decls.rsimmediately after the existingjs_string_matchdecl.crates/perry-runtime/src/regex.rs::js_string_match_all: outer-array slots holding the per-match inner array were being stored asf64::from_bits(inner_ptr as u64)(raw pointer bits). The codegenIndexGetfast paths (post-Array's hole should be undefined rather than 0 #323) expect NaN-boxed slot values, som[1]/m[2]would have read back nonsense without this fix. Switched tojs_nanbox_pointer(inner as i64)— same convention asjs_array_groupatarray.rs:1493and as the inner string elements.test-files/test_issue_317_string_matchall.tscovers: the issue's literal repro (for...ofover/([a-z]+)=([a-z]+)/gwith capture group access), three-capture-group dates with full-matchm[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 perrycleannode --experimental-strip-types test-files/test_issue_317_string_matchall.tsmatches Perry binary output byte-for-byteconsole_methodsci-env quirk)Closes #317.