summaryrefslogtreecommitdiff
path: root/test/infer-named.myr
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2013-04-01 14:45:47 -0400
committerOri Bernstein <ori@eigenstate.org>2013-04-01 14:45:47 -0400
commita64be799930f5f33d617f8e6933bfbcf5056080a (patch)
treefa78b525b59427d7c2bf6fc15f9af72f77b221e9 /test/infer-named.myr
parent105235911b6b3982f76f3d7e87070f696942c105 (diff)
downloadmc-a64be799930f5f33d617f8e6933bfbcf5056080a.tar.gz
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.
Diffstat (limited to 'test/infer-named.myr')
-rw-r--r--test/infer-named.myr21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/infer-named.myr b/test/infer-named.myr
new file mode 100644
index 0000000..002cc97
--- /dev/null
+++ b/test/infer-named.myr
@@ -0,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
+}