summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2017-07-01 14:43:22 -0700
committerOri Bernstein <ori@eigenstate.org>2017-07-03 23:27:02 -0700
commit871ef281aaf3c2e8bdff5d92355461bedfa5d933 (patch)
tree76db674822cd67fb1cd1772a8d52f40910735d00 /test
parentca10a1ec838b7d468a2b43894af659c111a0e9b1 (diff)
downloadmc-871ef281aaf3c2e8bdff5d92355461bedfa5d933.tar.gz
Specialize impl declarations on impl type in addition to decl type
This allows multiple specializations of a declarations with a concrete type, which can be selected with the new impl expression if it can't be deduced by its type alone. For example trait hasname @t = Name: byte[:] ;; impl hasname void = Name = "somename" ;; impl hasname bool = Name = "othername" ;; const boolname = impl(Name, void) To do this, pass the param type through to genericname and specializedcl. Since we now need the type parameter to look up trait decls, make sure n->expr.param gets the necessary treatment in typesub, specializenode, pickle, and unpickle. We also need to tag the param types for export.
Diffstat (limited to 'test')
-rw-r--r--test/implexpr-concrete.myr15
-rw-r--r--test/tests1
2 files changed, 16 insertions, 0 deletions
diff --git a/test/implexpr-concrete.myr b/test/implexpr-concrete.myr
new file mode 100644
index 0000000..9d5eeb1
--- /dev/null
+++ b/test/implexpr-concrete.myr
@@ -0,0 +1,15 @@
+use std
+
+trait name @a =
+ Name: byte[:]
+;;
+impl name void =
+ Name = "zig"
+;;
+impl name int =
+ Name = "zag"
+;;
+
+const main = {
+ std.put("{}{}\n", impl(Name, void), impl(Name, int))
+}
diff --git a/test/tests b/test/tests
index 937828b..b7ab8e1 100644
--- a/test/tests
+++ b/test/tests
@@ -165,3 +165,4 @@ B nestedgoto E 0
B initializer E 0
B fmtalign E 0
B implexpr P 12,z,hello
+B implexpr-concrete P zigzag