fix: count UTF-16 units for inline string length - #10228
proggeramlug wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (17)
Included review availability: Your plan provides up to 8 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughShort inline strings now report JavaScript UTF-16 lengths across runtime, generated-code, property, suffix-cursor, and element-shape paths. A shared runtime helper and call-free codegen lowering handle non-ASCII and malformed WTF-8 sequences. Regression tests cover JSON parsing and multiple access forms. ChangesSSO UTF-16 length handling
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to The short inline-string length fix is covered across runtime and generated paths, including non-ASCII and malformed inputs. No merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
JSON.parse('{"a":"é"}').a.lengthreturned2because inline strings store their UTF-8 byte length. It now returns1, matching JavaScript's UTF-16 code-unit semantics across runtime and generated property reads.Changes
Related issue
Fixes #10191
Test plan
RUST_TEST_THREADS=1 cargo test -p perry-runtime --lib value::now passes (54 tests).cargo test -p perry-codegen --lib element_shapepasses (70 tests).cargo test -p perry-codegen --lib lengthpasses (38 tests).cargo build -p perry -p perry-runtime-static -p perry-stdlib-staticin the default dev profile; verified artifact timestamps after the source changes.test-files/test_gap_10191_sso_utf16_length.tswith those archives and--no-auto-optimize; native stdout matches Node 26.5.1 byte-for-byte. The specialized clone is covered by the codegen tests; this source fixture's trace uses the ordinary generated length paths.python3 scripts/check_node_version_consistency.py, formatting, andgit diff --checkpass.scripts/pre-tag-check.sh --quickpasses except the existing public benchmark evidence freshness failure. Its checker, committed artifact, and all fingerprint inputs are unchanged from base6000a00dfe.Checklist
Cargo.lock,CLAUDE.md, orCHANGELOG.md.Summary by CodeRabbit
Bug Fixes
.lengthfor short strings containing non-ASCII characters to count UTF-16 code units, matching JavaScript behavior.Tests
CI follow-up
CI is not green. The runtime suite fails in
native_stack::tests::stack_top_respects_custom_thread_stack_sizes(bound must belong to this worker); the warnings gate reports unused WebAssembly helpers; and the checker self-test rejects a rawthread_local!inregex/perex_owner.rs. Those files are unchanged by this PR. Lint also reports the benchmark artifact freshness failure noted above.