fix(hir): preserve code points in typed string for-of - #10080
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 (4)
Included review availability: Your plan provides up to 8 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughString ChangesString for-of lowering
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to String iteration now preserves Unicode code points while retaining UTF-16 indexing behavior, with coverage for surrogate and control-flow cases. No actionable merge risk remains. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
Full details: Linked Issues checkExplanation The implementation satisfies the core coding requirements in Full details: Docstring CoverageExplanation Docstring coverage is 58.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 3 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 1📝 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
Typed string
for...ofloops now yield Unicode code points:ä中😀Öproduces four values, including the complete two-code-unit emoji. Both function-body and module-initialization lowering reuse the runtime string iterator's WTF-8 conversion before traversing anArray<String>.Changes
break,continue,return, nested iterator fallback, andfor await...of. Explicitly check that bracket indexing andcharCodeAtstill expose individual surrogate halves.This reuses existing conversion machinery and introduces O(n) temporary storage for typed string loops, including when a loop exits early. The ASCII control remains correct but is slower due to materialization (about 2.4–4.4× in this development-profile sweep). A streaming fast path would be a separate optimization. Unicode indexed-access prefix decoding is unchanged and remains tracked by #10055; no shared
string/char_ops.rsedits overlap #10055 or #10061.Related issue
Fixes #10062.
Test plan
origin/mainat603b074ace01464bc66fc07cc8d532f26ccf5a0f; reproduced the exact reported diagnostic and all three historical Unicode checksum mismatches. The new regression fails on the baseline compiler and passes with this change.cargo build --profile perry-dev --locked -p perry -p perry-runtime-static -p perry-stdlib-static, with matching archives pinned throughPERRY_RUNTIME_DIR, before and after.cargo test --profile perry-dev --locked -p perry-hir --lib -- --test-threads=1: 397 passed, 1 ignored.0,s, andz, both normally and under moving-GC stress. Each full stress run reported 476 copying minors / 19,675 moved objects and preserved the complete expected output.test_gap_9431_array_from_lone_surrogate.ts,test_gap_sso_concat_string_index.ts, andtest_gap_array_proto_iterator_replaced_7542.ts.git diff --check.Local native validation used Windows x64, Ryzen 5 7640HS, LLVM 22.1.8, the pinned Rust nightly, and the
perry-devprofile. The comprehensive/related fixtures usePERRY_RS4GC=0because their iterator/async lowering introduces Windows funclet EH, which the default RS4GC pipeline rejects under existing #7354. The issue's diagnostic and benchmarks use the default configuration. Stress used seed10062, rate1, allocation floor0, and evacuation verification.Screenshots / output
Exact bounded diagnostic:
Median milliseconds per invocation from the unchanged issue benchmark driver. These are development-profile measurements on this Windows host, not release-performance claims or comparisons with the issue's macOS baseline. Baseline Unicode timings below produced incorrect checksums.
Post-fix Unicode checksums:
383743935, 926322819, 754247844, 103819597, 618978563.ASCII checksums before and after:
379242312, 993701591, 233623069, 542806320, 180357488.Checklist
CLAUDE.md/CHANGELOG.md.fix:convention.CONTRIBUTING.mdand followed the Code of Conduct.Summary by CodeRabbit
Bug Fixes
for...ofloops so astral characters are yielded as complete code points instead of separate surrogate halves.charCodeAt.Tests