[m-rev.] diff: document problem with typeinfos deeply nested in typeclassinfos

Zoltan Somogyi zs at cs.mu.OZ.AU
Mon Sep 1 20:20:02 AEST 2003


Document a problem with the compiler and the debugger's treatment of type_infos
stored indirectly, not directly, inside typeclass_infos.

tests/debugger/deeply_nested_typeinfo.{m,inp,exp}:
	New test case to demonstrate the problem. The code is a cut-down
	version of tests/hard_coded/typeclasses/complicated_constraint.

tests/debugger/Mmakefile:
	Add the new test case, but do not enable it yet.

Zoltan.

cvs diff: Diffing .
Index: Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/Mmakefile,v
retrieving revision 1.96
diff -u -b -r1.96 Mmakefile
--- Mmakefile	17 Apr 2003 09:57:28 -0000	1.96
+++ Mmakefile	30 Aug 2003 14:37:50 -0000
@@ -38,6 +38,8 @@
 	resume_typeinfos		\
 	type_desc_test
 
+# We currently don't pass this test.
+#	deeply_nested_typeinfo
 # This test is currently not useful.
 #	output_term_dep
 
@@ -211,6 +213,10 @@
 
 debugger_regs.out: debugger_regs debugger_regs.inp
 	$(MDB) ./debugger_regs < debugger_regs.inp > debugger_regs.out 2>&1
+
+deeply_nested_typeinfo.out: deeply_nested_typeinfo deeply_nested_typeinfo.inp
+	$(MDB_STD) ./deeply_nested_typeinfo < deeply_nested_typeinfo.inp \
+		> deeply_nested_typeinfo.out 2>&1
 
 # The exception_cmd, exception_vars, polymorphic_output and loopcheck tests
 # are supposed to return a non-zero exit status, since they exit by throwing
Index: deeply_nested_typeinfo.exp
===================================================================
RCS file: deeply_nested_typeinfo.exp
diff -N deeply_nested_typeinfo.exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ deeply_nested_typeinfo.exp	1 Sep 2003 10:19:32 -0000
@@ -0,0 +1 @@
+NOT YET FILLED IN
Index: deeply_nested_typeinfo.inp
===================================================================
RCS file: deeply_nested_typeinfo.inp
diff -N deeply_nested_typeinfo.inp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ deeply_nested_typeinfo.inp	30 Aug 2003 14:12:39 -0000
@@ -0,0 +1,5 @@
+echo on
+register --quiet
+step
+print *
+continue -n -S
Index: deeply_nested_typeinfo.m
===================================================================
RCS file: deeply_nested_typeinfo.m
diff -N deeply_nested_typeinfo.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ deeply_nested_typeinfo.m	30 Aug 2003 14:31:37 -0000
@@ -0,0 +1,71 @@
+% This is the core of the hard_coded/typeclasses/complicated_constraint test
+% case. This code tests the compiler and the debugger's handling of predicates
+% whose signature includes a type variable which occurs in a typeclass
+% constraint but is not a direct argument of the typeclass constraint.
+% As a consequence, the typeinfo describing the type variable is available
+% neither as an argument nor directly inside a typeclassinfo, but only inside 
+% a typeinfo inside a typeclassinfo. Our RTTI design doesn't (yet) have
+% a mechanism for expressing this.
+%
+% There is also another reason why we can't handle this test case: the blah
+% predicate's type_info_varmap contains incorrect information: it implies
+% that the typeinfo for T is directly inside TypeClassInfo_for_foo, when the
+% only typeinfo directly inside TypeClassInfo_for_foo is the typeinfo for
+% list(T). This misleads the term size profiling transformation as well as
+% the parts of the compiler generating the debugger's RTTI.
+%
+% The relevant part of the HLDS dump:
+%
+% variable types map:
+% TypeClassInfo_for_foo (number 12): (private_builtin.typeclass_info((private_builtin.constraint((x.foo), (list.list(T))))))
+% type_info varmap:
+% T (number 1) -> typeclass_info(TypeClassInfo_for_foo, 1)  (number 12)
+% typeclass_info varmap:
+% x.foo((list.list(T))) -> TypeClassInfo_for_foo
+
+:- module deeply_nested_typeinfo.
+
+:- interface.
+
+:- import_module io.
+
+:- typeclass foo(A) where [
+	pred b(A::in) is semidet
+].
+
+:- instance foo(int).
+:- instance foo(list(T)) <= foo(T).
+
+:- pred main(io__state::di, io__state::uo) is det.
+
+:- implementation.
+:- import_module list, int.
+
+:- instance foo(int) where [
+	pred(b/1) is int_b
+].
+:- instance foo(list(T)) <= foo(T) where [
+	pred(b/1) is list_b
+].
+
+main -->
+	blah(101).
+
+:- pred list_b(list(T)::in) is semidet <= foo(T).
+
+list_b(List) :-
+	list__map((pred(A::in, A::out) is semidet :- b(A)), List, _).
+
+:- pred int_b(int::in) is semidet.
+
+int_b(1).
+
+:- pred blah(T, io__state, io__state) <= foo(list(T)).
+:- mode blah(in, di, uo) is det.
+
+blah(X) -->
+	( { b([X]) } ->
+		io__write_string("true\n")
+	;
+		io__write_string("false\n")
+	).
cvs diff: Diffing declarative
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list