Commit 533786b
fix(stdlib): prelude unwrap/unwrap_result diverge via panic (#134)
`prelude.affine`'s `unwrap` and `unwrap_result` only `println`'d on the
None/Err arm and then fell through, returning Unit from a `-> T`
signature (interpreter-era unsoundness; surfaced during #128 triage as
`Unify.TypeMismatch (T, Unit)`).
Replace the println+fall-through arms with `panic(...)` — the existing
`panic(String) -> Never` builtin, exactly as `option.affine` and
`result.affine` already do — so the failure arm has type Never and the
typed return is sound.
Adds two interpreter tests asserting the panic path (`unwrap(None)` and
`unwrap_result(Err _)` both raise the documented RuntimeError). Full
suite green (216 tests).
Closes #134
Refs #128
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent dab2f39 commit 533786b
2 files changed
Lines changed: 45 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
| 28 | + | |
32 | 29 | | |
33 | 30 | | |
34 | 31 | | |
| |||
62 | 59 | | |
63 | 60 | | |
64 | 61 | | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
| 62 | + | |
69 | 63 | | |
70 | 64 | | |
71 | 65 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
774 | 774 | | |
775 | 775 | | |
776 | 776 | | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
777 | 818 | | |
778 | 819 | | |
779 | 820 | | |
780 | 821 | | |
781 | 822 | | |
782 | 823 | | |
| 824 | + | |
| 825 | + | |
783 | 826 | | |
784 | 827 | | |
785 | 828 | | |
| |||
0 commit comments