[m-rev.] diff: add a further test of repeated type variables in instance heads
Julien Fischer
jfischer at opturion.com
Tue Jul 9 15:33:14 AEST 2013
Add a further test of repeated type variables in instance heads.
tests/invalid/repeated_instance_vars_unsat.{m,err_exp}:
Check that we get an error if a repeated type variable is bound
to different types.
tests/invalid/Mmakefile:
Add the above test.
Julien.
diff --git a/tests/invalid/Mmakefile b/tests/invalid/Mmakefile
index 72826fc..4ead6eb 100644
--- a/tests/invalid/Mmakefile
+++ b/tests/invalid/Mmakefile
@@ -184,6 +184,7 @@ SINGLEMODULE= \
quant_constraint_2 \
range_restrict \
record_syntax_errors \
+ repeated_instance_vars_unsat \
require_det_in_lambda \
require_scopes \
some \
diff --git a/tests/invalid/repeated_instance_vars_unsat.err_exp b/tests/invalid/repeated_instance_vars_unsat.err_exp
new file mode 100644
index 0000000..71640c1
--- /dev/null
+++ b/tests/invalid/repeated_instance_vars_unsat.err_exp
@@ -0,0 +1,3 @@
+repeated_instance_vars_unsat.m:024: In clause for predicate `test'/2:
+repeated_instance_vars_unsat.m:024: unsatisfiable typeclass constraint:
+repeated_instance_vars_unsat.m:024: `repeated_instance_vars_unsat.foo(list.list(int), list.list(float))'.
diff --git a/tests/invalid/repeated_instance_vars_unsat.m b/tests/invalid/repeated_instance_vars_unsat.m
new file mode 100644
index 0000000..c2ec5bc
--- /dev/null
+++ b/tests/invalid/repeated_instance_vars_unsat.m
@@ -0,0 +1,24 @@
+% Check that we get an error if a repeated type variable in an instance head
+% is bound to different types.
+%
+:- module repeated_instance_vars_unsat.
+:- interface.
+
+:- import_module list.
+
+:- typeclass foo(A, B) where [
+ pred method1(A::in, B::in) is semidet
+].
+
+:- instance foo(list(T), list(T)).
+
+:- pred test(list(int)::in, list(float)::in) is semidet.
+
+:- implementation.
+
+:- instance foo(list(T), list(T)) where [
+ ( method1([_ | _], [_ | _] ) )
+].
+
+test(Ints, Floats) :-
+ method1(Ints, Floats).
More information about the reviews
mailing list