Skip to content

Commit a3392df

Browse files
committed
Add another generalization test
1 parent 0725752 commit a3392df

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

scrapscript.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4669,6 +4669,12 @@ def test_generalization(self) -> None:
46694669
ty = self.infer(expr, {})
46704670
self.assertTyEqual(ty, func_type(TyVar("a"), TyVar("a")))
46714671

4672+
def test_generalization2(self) -> None:
4673+
# From https://okmij.org/ftp/ML/generalization.html
4674+
expr = parse(tokenize("x -> (y . y = z -> x z)"))
4675+
ty = self.infer(expr, {})
4676+
self.assertTyEqual(ty, func_type(func_type(TyVar("a"), TyVar("b")), func_type(TyVar("a"), TyVar("b"))))
4677+
46724678
def test_id(self) -> None:
46734679
expr = Function(Var("x"), Var("x"))
46744680
ty = self.infer(expr, {})

0 commit comments

Comments
 (0)