diff --git a/client/test/suite.t/error-cycle.midml b/client/test/suite.t/error-cycle.midml new file mode 100644 index 0000000000000000000000000000000000000000..c3f189f1fc89f30dbd6869cfc5ec615eaec870de --- /dev/null +++ b/client/test/suite.t/error-cycle.midml @@ -0,0 +1 @@ +let self_app = fun x -> x x diff --git a/client/test/suite.t/error-unbound.midml b/client/test/suite.t/error-unbound.midml new file mode 100644 index 0000000000000000000000000000000000000000..1d840c80279154e69876d227b325dab6a1398b8b --- /dev/null +++ b/client/test/suite.t/error-unbound.midml @@ -0,0 +1 @@ +let x = (fun y -> z) diff --git a/client/test/suite.t/error-unify-app-arg.midml b/client/test/suite.t/error-unify-app-arg.midml new file mode 100644 index 0000000000000000000000000000000000000000..f6c72f5bd7e94a67f93a9b47154d431c7749b7da --- /dev/null +++ b/client/test/suite.t/error-unify-app-arg.midml @@ -0,0 +1,2 @@ +let x = + (fun y z -> y z) () diff --git a/client/test/suite.t/error-unify-app-fun.midml b/client/test/suite.t/error-unify-app-fun.midml new file mode 100644 index 0000000000000000000000000000000000000000..495dd5cdb070c02bb6fe90c6f5a2e45913ffbe33 --- /dev/null +++ b/client/test/suite.t/error-unify-app-fun.midml @@ -0,0 +1,2 @@ +let app_error = fun x -> + (x, x) (fun y -> y) diff --git a/client/test/suite.t/error-unify-letprod.midml b/client/test/suite.t/error-unify-letprod.midml new file mode 100644 index 0000000000000000000000000000000000000000..64ae2f0d08b56cf6c49ce42bc194626c8463900e --- /dev/null +++ b/client/test/suite.t/error-unify-letprod.midml @@ -0,0 +1,2 @@ +let letprod_error = + let (x, y) = (fun z -> z) in x diff --git a/client/test/suite.t/error-variable-scope-escape.midml b/client/test/suite.t/error-variable-scope-escape.midml new file mode 100644 index 0000000000000000000000000000000000000000..5c4ec498f5820337b6611b4d91572c4c3cdae700 --- /dev/null +++ b/client/test/suite.t/error-variable-scope-escape.midml @@ -0,0 +1,2 @@ +let rigid_escape = fun f -> + (fun x -> f x : for 'a . 'a -> 'a) diff --git a/client/test/suite.t/run.t b/client/test/suite.t/run.t index 5ba32dcdb62f5861524516fd6b311620c9c8bc19..8b8ef784ba692980371fdcb6c6a0730f9bf5616d 100644 --- a/client/test/suite.t/run.t +++ b/client/test/suite.t/run.t @@ -1,4 +1,4 @@ -Basics +# Basics $ cat id.midml let id = @@ -63,7 +63,79 @@ Basics File "test", line 2, characters 10-10: Syntax error. -Option type +# Errors + +Unbound variables. + + $ cat error-unbound.midml + let x = (fun y -> z) + + $ midml error-unbound.midml + Type inference and translation to System F... + File "test", line 1, characters 18-19: + Type error: unbound variable "z". + +Some unification errors (not exhaustive!) + + $ cat error-unify-letprod.midml + let letprod_error = + let (x, y) = (fun z -> z) in x + + $ midml error-unify-letprod.midml + Type inference and translation to System F... + File "test", line 2, characters 16-26: + Type error: mismatch between the type: + {r2*r4} + and the type: + r8 -> r10 + + $ cat error-unify-app-fun.midml + let app_error = fun x -> + (x, x) (fun y -> y) + + $ midml error-unify-app-fun.midml + Type inference and translation to System F... + File "test", line 2, characters 2-8: + Type error: mismatch between the type: + r8 -> r4 + and the type: + {r12*r14} + + $ cat error-unify-app-arg.midml + let x = + (fun y z -> y z) () + + $ midml error-unify-app-arg.midml + Type inference and translation to System F... + File "test", line 2, characters 19-21: + Type error: mismatch between the type: + r12 -> r14 + and the type: + {} + +Cycles + + $ cat error-cycle.midml + let self_app = fun x -> x x + + $ midml error-cycle.midml + Type inference and translation to System F... + File "test", line 1, characters 15-27: + Type error: a cyclic type arose. + mu a0. a0 -> r4 + +Variable scope escape + + $ cat error-variable-scope-escape.midml + let rigid_escape = fun f -> + (fun x -> f x : for 'a . 'a -> 'a) + + $ midml error-variable-scope-escape.midml + Type inference and translation to System F... + File "test", line 2, characters 2-36: + A rigid variable escapes its scope. + +# Option type $ cat none.midml #use option.midml @@ -108,7 +180,7 @@ Option type Converting the System F term to de Bruijn style... Type-checking the System F term... -List type +# List type $ cat nil.midml #use list.midml @@ -178,7 +250,7 @@ List type Converting the System F term to de Bruijn style... Type-checking the System F term... -Annotations +# Annotations $ cat nat-annot.midml type nat = | Zero | Succ of nat @@ -192,7 +264,7 @@ Annotations Converting the System F term to de Bruijn style... Type-checking the System F term... -Pattern-matching +# Pattern-matching $ cat match-tuple.midml let _ =