summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2016-01-31 22:18:17 -0800
committerOri Bernstein <ori@eigenstate.org>2016-01-31 22:49:31 -0800
commit128470e404d843b3d71c5837cac05d4d4203bd66 (patch)
tree267d7879867aebd35a7f8203d0ff9f77fb9238f0 /test
parentfb8753c942a8d06926977d221d5c89c3a867fa29 (diff)
downloadmc-128470e404d843b3d71c5837cac05d4d4203bd66.tar.gz
Add support for generic impls.
You can now implement generic shit like iterators.
Diffstat (limited to 'test')
-rw-r--r--test/genericimpl.myr33
-rw-r--r--test/tests1
2 files changed, 34 insertions, 0 deletions
diff --git a/test/genericimpl.myr b/test/genericimpl.myr
new file mode 100644
index 0000000..ef8e094
--- /dev/null
+++ b/test/genericimpl.myr
@@ -0,0 +1,33 @@
+use std
+
+trait gimpl @a =
+ desc : (x : @a -> byte[:])
+;;
+
+impl gimpl int =
+ desc = {x
+ -> "int"
+ }
+;;
+
+impl gimpl byte[:] =
+ desc = {x
+ -> "string"
+ }
+;;
+
+impl gimpl @a =
+ desc = {x
+ -> "@a"
+ }
+;;
+
+impl gimpl @b[:] =
+ desc = {x
+ -> "@a[:]"
+ }
+;;
+
+const main = {
+ std.put("{} {} {} {}\n", desc(123), desc("foo"), desc('x'), desc([true][:]))
+}
diff --git a/test/tests b/test/tests
index d7c10d9..4ed8cdd 100644
--- a/test/tests
+++ b/test/tests
@@ -93,6 +93,7 @@ B generictype E 0
B genericret E 42
B genericmatch E 15
B genericrec E 0
+B genericimpl P 'int string @a @a[:]'
B recgeneric P 'built'
B bigtyblob P '`U100 '
# B genericchain P 'val = 123' ## BUGGERED