ref: a64be799930f5f33d617f8e6933bfbcf5056080a
parent: 105235911b6b3982f76f3d7e87070f696942c105
author: Ori Bernstein <[email protected]>
date: Mon Apr 1 10:45:47 EDT 2013
Add a broken test for inferring named types. Currently, we take the actual type of compound literals, and set that as their type. This is wrong, since it doesn't take into account named types. Instead, we should substitute the type with a type parameter, and do a post-unification pass checking the base type, similar to how we do a post pass to check integers. The test added should work to verify this.
--- /dev/null
+++ b/test/infer-named.myr
@@ -1,0 +1,21 @@
+use std
+
+type u = union
+ `Foo
+ `Bar int
+;;
+
+const f = {v : int -> u
+ -> `Bar v
+}
+
+const main = {
+ var v
+
+ v = f(99)
+ match v
+ `Foo: -> 1;;
+ `Bar x: -> x;;
+ ;;
+ -> 2
+}
--- a/test/tests
+++ b/test/tests
@@ -76,6 +76,7 @@
B tuple E 42
B slgrow E 42
B tyrec E 42
+B infer-named E 99
B helloworld P Hello-世界
B catfile P Hello-世界
B encodechar P 1世界äa