Commit 26cd0f3
encoding.cbor: build option payloads via comptime
The generic struct decoder recovered an option field's payload type through a
helper whose only job was to abuse generic inference:
fn create_value_from_optional[T](_val ?T) T { return T{} }
#27048 makes `$zero(TypeExpr)` resolve per-field comptime metadata, so the
payload type can be read directly at the `$for field` site. Replace the call with
`$zero(field.typ.payload_type)` and drop the helper.
No behavior change: the helper unconditionally returned `T{}` (zero of the payload),
exactly what `$zero(field.typ.payload_type)` yields; `inner` is then filled by
`unpack_into`. The full `vlib/encoding/cbor` suite (10 files) still passes.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>$zero(field.typ.payload_type)
1 parent 8520724 commit 26cd0f3
1 file changed
Lines changed: 1 addition & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
416 | 416 | | |
417 | 417 | | |
418 | 418 | | |
419 | | - | |
| 419 | + | |
420 | 420 | | |
421 | 421 | | |
422 | 422 | | |
| |||
570 | 570 | | |
571 | 571 | | |
572 | 572 | | |
573 | | - | |
574 | | - | |
575 | | - | |
576 | | - | |
577 | | - | |
578 | | - | |
579 | 573 | | |
580 | 574 | | |
581 | 575 | | |
| |||
0 commit comments