Commit 8fd46d8
fix(typecheck): generalize parametric enum ctor schemes via shared param tyvars (#128)
register_type_decl's TyEnum branch built result_ty tyvars with an
anonymous fresh_tyvar 0 and never bound the declared param names, so
(a) field types and the result type used disconnected vars and
(b) generalize was a no-op at level 0 -> imported parametric ctor
schemes (prelude Ok/Err/Some) were monomorphic with shared vars,
collapsing payload types across use-sites on the import path.
Bind param names to fresh tyvars one level deeper so result and field
types share them, generalize at the outer level, and scope the param
names so they don't leak into sibling type decls.
Fixes stdlib/result.affine; stdlib 14->15/19; 233/233 dune test, zero regression.
Refs #128
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent c332b60 commit 8fd46d8
1 file changed
Lines changed: 35 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1527 | 1527 | | |
1528 | 1528 | | |
1529 | 1529 | | |
1530 | | - | |
1531 | | - | |
| 1530 | + | |
| 1531 | + | |
| 1532 | + | |
| 1533 | + | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
1532 | 1553 | | |
1533 | | - | |
1534 | | - | |
1535 | | - | |
1536 | | - | |
1537 | | - | |
1538 | | - | |
1539 | | - | |
1540 | | - | |
1541 | | - | |
| 1554 | + | |
1542 | 1555 | | |
1543 | | - | |
| 1556 | + | |
1544 | 1557 | | |
1545 | 1558 | | |
1546 | 1559 | | |
1547 | | - | |
1548 | | - | |
| 1560 | + | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
1549 | 1567 | | |
1550 | 1568 | | |
1551 | 1569 | | |
1552 | | - | |
1553 | | - | |
1554 | | - | |
1555 | | - | |
1556 | | - | |
1557 | | - | |
1558 | | - | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
1559 | 1573 | | |
1560 | 1574 | | |
1561 | 1575 | | |
| |||
0 commit comments