Commit 9b6d12c
* fix(intl): #5581 — NumberFormat option read order, useGrouping/roundingIncrement validation, and format accessor
Closes 10 test262 intl402/NumberFormat cases by aligning the constructor's
GetOption sequence and the `format` accessor shape with ECMA-402.
SetNumberFormatDigitOptions / CreateNumberFormat:
- Read `localeMatcher` first (it was never read), then keep the exact GetOption
order the spec asserts: roundingIncrement, roundingMode, roundingPriority now
read in sequence instead of roundingPriority jumping ahead of the others.
(constructor-option-read-order, constructor-options-throwing-getters)
- `roundingIncrement` is ToNumber-coerced (so `{ valueOf }` / string options
work) and validated against the sanctioned increment set rather than a bare
[1, 5000] range; a non-1 increment now requires the default fraction-digit
rounding type (TypeError otherwise) with maxFrac == minFrac (RangeError
otherwise). (constructor-roundingIncrement[-invalid])
- `useGrouping` follows GetStringOrBooleanOption exactly: boolean true → "always",
any ToBoolean-false value (false/0/null/"") → false, the strings "true"/"false"
fall back to the default, and only "min2"/"auto"/"always" are otherwise valid.
(test-option-useGrouping[-extended])
format accessor:
- `Intl.NumberFormat.prototype.format` is now a getter (name "get format",
length 0) returning the instance's bound format function (name "", length 1),
matching the ECMA-402 [[BoundFormat]] shape. Instances keep an own bound
`format` for the hot dispatch path. (format/{length,name,prop-desc,
no-instanceof,format-function-name})
- install_constructor gained a getters slice; only NumberFormat uses it.
Verified against test262 @ 4249661 with Node v26.3.0: NumberFormat subset goes
from 106 to 121 passing with no regressions; no parity changes in the existing
Intl node-suite differential.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(intl): back NumberFormat [[BoundFormat]] with a hidden slot; cargo fmt
CodeRabbit review follow-up:
- The `format` getter now reads the bound format function from a hidden
KEY_NF_BOUND_FORMAT slot instead of the public own `format` property, so
`nf.format = 1` / `delete nf.format` can no longer corrupt what
`Object.getOwnPropertyDescriptor(proto, "format").get.call(nf)` returns. The
own `format` property is retained only for the native dispatch fast path.
- Applied `cargo fmt`.
(CodeRabbit's second finding — that `roundingIncrement !== 1` should resolve the
default fraction width to 0/0 instead of throwing — does not match Node v26:
`new Intl.NumberFormat("en", { roundingIncrement: 5 })` and
`{ roundingIncrement: 5, maximumFractionDigits: 2 }` both throw RangeError there,
matching this implementation.)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* style: cargo fmt the bound-format slot assignment
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Ralph <ralph@skelpo.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent de866a9 commit 9b6d12c
3 files changed
Lines changed: 184 additions & 54 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
70 | 71 | | |
71 | 72 | | |
72 | 73 | | |
| |||
148 | 149 | | |
149 | 150 | | |
150 | 151 | | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
151 | 157 | | |
152 | 158 | | |
153 | 159 | | |
| |||
306 | 312 | | |
307 | 313 | | |
308 | 314 | | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
309 | 318 | | |
310 | 319 | | |
311 | 320 | | |
312 | | - | |
313 | | - | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
314 | 324 | | |
315 | | - | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
316 | 332 | | |
317 | 333 | | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | 334 | | |
322 | 335 | | |
323 | 336 | | |
324 | 337 | | |
| 338 | + | |
325 | 339 | | |
326 | | - | |
327 | | - | |
328 | 340 | | |
329 | 341 | | |
330 | 342 | | |
| |||
797 | 809 | | |
798 | 810 | | |
799 | 811 | | |
800 | | - | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
801 | 820 | | |
802 | 821 | | |
803 | 822 | | |
804 | 823 | | |
805 | 824 | | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
806 | 833 | | |
807 | 834 | | |
808 | 835 | | |
| |||
1150 | 1177 | | |
1151 | 1178 | | |
1152 | 1179 | | |
1153 | | - | |
| 1180 | + | |
1154 | 1181 | | |
1155 | 1182 | | |
1156 | | - | |
| 1183 | + | |
1157 | 1184 | | |
1158 | 1185 | | |
1159 | 1186 | | |
| |||
1171 | 1198 | | |
1172 | 1199 | | |
1173 | 1200 | | |
| 1201 | + | |
1174 | 1202 | | |
1175 | 1203 | | |
1176 | 1204 | | |
| |||
1306 | 1334 | | |
1307 | 1335 | | |
1308 | 1336 | | |
| 1337 | + | |
1309 | 1338 | | |
1310 | 1339 | | |
1311 | 1340 | | |
| |||
1326 | 1355 | | |
1327 | 1356 | | |
1328 | 1357 | | |
1329 | | - | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
1330 | 1362 | | |
1331 | 1363 | | |
1332 | 1364 | | |
1333 | 1365 | | |
1334 | 1366 | | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
1335 | 1395 | | |
1336 | 1396 | | |
1337 | 1397 | | |
| |||
1384 | 1444 | | |
1385 | 1445 | | |
1386 | 1446 | | |
1387 | | - | |
1388 | 1447 | | |
1389 | 1448 | | |
1390 | 1449 | | |
| |||
1396 | 1455 | | |
1397 | 1456 | | |
1398 | 1457 | | |
| 1458 | + | |
| 1459 | + | |
1399 | 1460 | | |
1400 | 1461 | | |
1401 | 1462 | | |
| |||
1421 | 1482 | | |
1422 | 1483 | | |
1423 | 1484 | | |
| 1485 | + | |
1424 | 1486 | | |
1425 | 1487 | | |
1426 | 1488 | | |
| |||
1435 | 1497 | | |
1436 | 1498 | | |
1437 | 1499 | | |
| 1500 | + | |
1438 | 1501 | | |
1439 | 1502 | | |
1440 | 1503 | | |
| |||
1449 | 1512 | | |
1450 | 1513 | | |
1451 | 1514 | | |
| 1515 | + | |
1452 | 1516 | | |
1453 | 1517 | | |
1454 | 1518 | | |
| |||
1464 | 1528 | | |
1465 | 1529 | | |
1466 | 1530 | | |
| 1531 | + | |
1467 | 1532 | | |
1468 | 1533 | | |
1469 | 1534 | | |
| |||
1479 | 1544 | | |
1480 | 1545 | | |
1481 | 1546 | | |
| 1547 | + | |
1482 | 1548 | | |
1483 | 1549 | | |
1484 | 1550 | | |
| |||
1498 | 1564 | | |
1499 | 1565 | | |
1500 | 1566 | | |
| 1567 | + | |
1501 | 1568 | | |
1502 | 1569 | | |
1503 | 1570 | | |
| |||
1517 | 1584 | | |
1518 | 1585 | | |
1519 | 1586 | | |
| 1587 | + | |
1520 | 1588 | | |
1521 | 1589 | | |
1522 | 1590 | | |
| |||
1531 | 1599 | | |
1532 | 1600 | | |
1533 | 1601 | | |
| 1602 | + | |
1534 | 1603 | | |
1535 | 1604 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
751 | 751 | | |
752 | 752 | | |
753 | 753 | | |
754 | | - | |
755 | | - | |
756 | | - | |
757 | | - | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
758 | 761 | | |
759 | | - | |
| 762 | + | |
760 | 763 | | |
761 | 764 | | |
762 | 765 | | |
| |||
0 commit comments