Commit f8ee956
committed
internal/encoding/yaml/goccy: resolve scalar numbers by syntax rules
numberKind mirrored the yaml.v3 resolver through Go's strconv
functions, inheriting artifacts that belong to neither YAML nor CUE:
integers were bounded to 64 bits, so larger decimal integers decoded
as the float form `number & N` and larger hexadecimals fell back to
strings, even though YAML and CUE integers have no size limit, and
values shaped like broken YAML 1.1 octals, such as `0778`, resolved
as floats and needed a carve-out to reach their string interpretation.
Resolve numbers by declared syntax rules instead: the YAML 1.2 core
schema forms extended with the YAML 1.1 forms CUE keeps supporting,
namely leading-zero octals, binary integers, a sign before any base,
and underscore separators. Integers of any size in any base now
decode as CUE integers, the `0778` carve-out disappears since a
decimal integer must not start with a zero digit, and `number & N`
remains only for scalars tagged `!!float` whose value is written as
an integer. The rxAnyOctalYaml11 pattern moves to the goccy encoder
added by a follow-up change, whose quoting still relies on it.
Converting YAML 1.1 octals to CUE form is now also limited to integer
shapes and understands signs. It previously fired on any value with a
leading zero digit, so valid YAML floats such as `01289.5` were
mangled into `0o1289.5` and failed to decode, and it ignored signed
octals such as `-0123`, which then failed to decode as invalid CUE.
Both bugs are shared with the yaml.v3 based decoder, where they
remain; the yamlgoccy experiment covers the transition.
Signed-off-by: Matthew Sackman <matthew@cue.works>
Assisted-by: Claude Code (claude-fable-5)
Change-Id: Ie93e11aa537efceebb91ade0c699acf96d93f8a6
Reviewed-on: https://cue.gerrithub.io/c/cue-lang/cue/+/1244090
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>1 parent cf81409 commit f8ee956
3 files changed
Lines changed: 66 additions & 56 deletions
File tree
- cmd/cue/cmd/testdata/script
- internal/encoding/yaml/goccy
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1454 | 1454 | | |
1455 | 1455 | | |
1456 | 1456 | | |
1457 | | - | |
1458 | | - | |
1459 | | - | |
1460 | | - | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
1461 | 1466 | | |
1462 | 1467 | | |
1463 | | - | |
1464 | | - | |
1465 | | - | |
1466 | | - | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
1467 | 1475 | | |
1468 | 1476 | | |
1469 | 1477 | | |
| |||
1477 | 1485 | | |
1478 | 1486 | | |
1479 | 1487 | | |
1480 | | - | |
1481 | | - | |
1482 | | - | |
1483 | | - | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
1484 | 1494 | | |
1485 | | - | |
| 1495 | + | |
1486 | 1496 | | |
1487 | 1497 | | |
1488 | | - | |
1489 | | - | |
1490 | | - | |
1491 | | - | |
1492 | | - | |
1493 | | - | |
1494 | | - | |
1495 | | - | |
1496 | | - | |
1497 | | - | |
1498 | | - | |
1499 | | - | |
1500 | | - | |
1501 | | - | |
1502 | | - | |
1503 | | - | |
1504 | | - | |
1505 | | - | |
1506 | | - | |
1507 | | - | |
1508 | | - | |
1509 | | - | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
| 1505 | + | |
1510 | 1506 | | |
1511 | 1507 | | |
1512 | 1508 | | |
| |||
1529 | 1525 | | |
1530 | 1526 | | |
1531 | 1527 | | |
1532 | | - | |
1533 | | - | |
1534 | | - | |
1535 | | - | |
1536 | | - | |
1537 | | - | |
| 1528 | + | |
1538 | 1529 | | |
1539 | 1530 | | |
1540 | 1531 | | |
1541 | 1532 | | |
1542 | 1533 | | |
1543 | | - | |
1544 | | - | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
1545 | 1537 | | |
1546 | | - | |
1547 | | - | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
1548 | 1550 | | |
1549 | | - | |
| 1551 | + | |
1550 | 1552 | | |
1551 | 1553 | | |
1552 | 1554 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
155 | 158 | | |
156 | 159 | | |
157 | 160 | | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
158 | 164 | | |
159 | 165 | | |
160 | 166 | | |
| |||
400 | 406 | | |
401 | 407 | | |
402 | 408 | | |
403 | | - | |
| 409 | + | |
404 | 410 | | |
405 | 411 | | |
406 | 412 | | |
| |||
416 | 422 | | |
417 | 423 | | |
418 | 424 | | |
419 | | - | |
420 | | - | |
421 | | - | |
422 | | - | |
| 425 | + | |
| 426 | + | |
423 | 427 | | |
424 | 428 | | |
425 | | - | |
| 429 | + | |
426 | 430 | | |
427 | 431 | | |
428 | 432 | | |
429 | | - | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
430 | 438 | | |
431 | 439 | | |
432 | 440 | | |
433 | 441 | | |
434 | | - | |
| 442 | + | |
435 | 443 | | |
436 | 444 | | |
437 | 445 | | |
| |||
450 | 458 | | |
451 | 459 | | |
452 | 460 | | |
453 | | - | |
| 461 | + | |
454 | 462 | | |
455 | 463 | | |
456 | 464 | | |
| |||
0 commit comments