Commit c332b60
check_pattern's PatCon read the monomorphic constructor_env entry and
wrapped it as a 0-tyvar scheme, so every occurrence of a constructor
shared one set of type variables. Two `Ok(_)` patterns in a single
match (e.g. result.affine `apply`'s tuple match) thus forced both
payloads to the same type, yielding `Unify ((_ -> _), T)`.
Now prefer the polymorphic scheme bound in name_types (set via
bind_scheme for builtin Ok/Err/Some/None/RuntimeError and user
variants) and instantiate it fresh per occurrence — exactly as
lookup_var does for ordinary identifiers — falling back to the
constructor_env entry only when no scheme is registered.
Correctness/soundness fix. Full suite 233/233, zero regression.
(result.affine remains blocked on a separate import-path issue:
imported parametric ctor schemes are built with fresh_tyvar 0 then
generalize, a no-op at level 0 — tracked for the next slice.)
Refs #128.
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent e3d4806 commit c332b60
1 file changed
Lines changed: 23 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
488 | 488 | | |
489 | 489 | | |
490 | 490 | | |
491 | | - | |
492 | | - | |
493 | | - | |
494 | | - | |
495 | | - | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
496 | 514 | | |
497 | 515 | | |
498 | 516 | | |
| |||
0 commit comments