Commit 414b7ae
x.json2: decode option fields via comptime
Build option payloads with `$zero(field.typ.payload_type)` and option pointer
payloads with `$new(field.typ.payload_type.pointee_type)`, resolving each field's
payload directly at the comptime field site.
This replaces the `create_value_from_optional` and `create_decoded_option_ptr`
generic helpers, which existed only to work around options not being passable to
generic functions (the limitation lifted by #27048). The accompanying
`or {}` fallbacks were dead code: `create_value_from_optional` always returned a
value and never `none`.
No behavior change; the full `vlib/x/json2` suite (61 files) still passes,
including the `?&T` option-pointer regression in decode_embed_reference_test.v.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>$zero/$new type accessors1 parent 8520724 commit 414b7ae
1 file changed
Lines changed: 4 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
335 | 335 | | |
336 | 336 | | |
337 | 337 | | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | 338 | | |
343 | 339 | | |
344 | 340 | | |
| |||
551 | 547 | | |
552 | 548 | | |
553 | 549 | | |
554 | | - | |
| 550 | + | |
555 | 551 | | |
556 | 552 | | |
557 | 553 | | |
558 | | - | |
559 | | - | |
560 | | - | |
561 | | - | |
562 | | - | |
563 | | - | |
| 554 | + | |
564 | 555 | | |
565 | 556 | | |
566 | 557 | | |
| |||
916 | 907 | | |
917 | 908 | | |
918 | 909 | | |
919 | | - | |
920 | | - | |
921 | 910 | | |
922 | 911 | | |
923 | 912 | | |
| |||
926 | 915 | | |
927 | 916 | | |
928 | 917 | | |
929 | | - | |
930 | | - | |
| 918 | + | |
931 | 919 | | |
932 | 920 | | |
933 | 921 | | |
934 | | - | |
935 | | - | |
936 | | - | |
| 922 | + | |
937 | 923 | | |
938 | 924 | | |
939 | 925 | | |
| |||
1307 | 1293 | | |
1308 | 1294 | | |
1309 | 1295 | | |
1310 | | - | |
1311 | | - | |
1312 | | - | |
1313 | | - | |
1314 | 1296 | | |
1315 | 1297 | | |
1316 | 1298 | | |
| |||
0 commit comments