fix(intl): #5581 — formatRange equal endpoints use approximate form#5773
Conversation
Follow-up to #5771 (CodeRabbit). ECMA-402 PartitionNumberRangePattern renders the approximate ("~") form whenever the two endpoints format to the same string — including mathematically equal endpoints. The merged code special-cased equal endpoints to a plain single value, so `formatRange(3, 3)` returned "3" and `formatRangeToParts(3, 3)` omitted the `approximatelySign`, diverging from the spec and from Node: new Intl.NumberFormat("en-US").formatRange(3, 3) // "~3" new Intl.NumberFormat("en-US").formatRangeToParts(3, 3) // [{approximatelySign,~,shared},{integer,3,shared}] Drop the `range_endpoints_equal` fast path so equal endpoints flow through the existing `sx == sy` approximate branch. Verified byte-for-byte against node v26 and the pinned test262 corpus (intl402/NumberFormat formatRange /formatRangeToParts: 16 pass / 3 fail unchanged, 0 compile failures). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
Intl.NumberFormat formatRange approximate collapse
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 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
Follow-up to #5771 addressing a CodeRabbit correctness flag that landed after that PR merged.
Per ECMA-402
PartitionNumberRangePattern,Intl.NumberFormat.prototype.formatRangerenders the approximate (~) form whenever the two endpoints format to the same string — and this includes mathematically equal endpoints. #5771 special-cased equal endpoints to a plain single value, diverging from the spec and from the Node oracle:Change
Drop the
range_endpoints_equalfast path so equal endpoints flow through the existingsx == syapproximate branch in bothformatRangeandformatRangeToParts.Validation
node v26byte-for-byte forformatRange(3,3)/formatRangeToParts(3,3).intl402/NumberFormat/prototype/{formatRange,formatRangeToParts}): 16 pass / 3 fail unchanged, 0 compile failures — no test-count regression (the remaining 3 are the exact-ICU-formatting cases out of scope for fix(intl): #5581 — add Intl.NumberFormat formatRange/formatRangeToParts #5771).Refs #5581.
🤖 Generated with Claude Code
Summary by CodeRabbit