for review: polymorphic unification not (in, in)
David Glen JEFFERY
dgj at cs.mu.OZ.AU
Mon Nov 9 16:23:52 AEDT 1998
Hi Fergus,
How does this look?
--------------------------------------------------------------
Estimated hours taken: 2
compiler/polymorphism.m:
Abort if there is a polymorphic unification that is in
a partially instantiated mode. This error should be
caught earlier (probably during mode analysis), but it's
best to abort rather than just go ahead and generate
bad code.
tests/invalid/polymorphic_unification.m:
tests/invalid/polymorphic_unification.err_exp:
A test case for the above change.
tests/invalid/Mmakefile:
Turn this test case on.
Index: polymorphism.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/polymorphism.m,v
retrieving revision 1.153
diff -u -t -r1.153 polymorphism.m
--- polymorphism.m 1998/10/15 09:25:11 1.153
+++ polymorphism.m 1998/11/09 05:22:33
@@ -947,10 +947,11 @@
;
error("polymorphism.m: can't find `builtin:unify/2'")
},
- % XXX Bug! - we should check that the mode is (in, in),
- % and report an error (e.g. "unification of
- % polymorphically typed variables in partially
- % instantiated mode") if it isn't
+ { Mode = XMode - YMode },
+ { require(mode_is_fully_input(ModuleInfo, XMode),
+ "Sorry, not implemented: polymorphic unification in mode other than (in, in)") },
+ { require(mode_is_fully_input(ModuleInfo, YMode),
+ "Sorry, not implemented: polymorphic unification in mode other than (in, in)") },
{ hlds_pred__in_in_unification_proc_id(ProcId) },
{ map__lookup(TypeInfoMap, TypeVar, TypeInfoLocn) },
{ SymName = unqualified("unify") },
cvs diff: Diffing .
Index: Mmakefile
===================================================================
RCS file: /home/staff/zs/imp/tests/invalid/Mmakefile,v
retrieving revision 1.35
diff -u -t -r1.35 Mmakefile
--- Mmakefile 1998/10/29 14:59:12 1.35
+++ Mmakefile 1998/11/09 05:16:14
@@ -34,6 +34,7 @@
no_exports.m \
nullary_ho_func_error.m \
occurs.m \
+ polymorphic_unification.m \
pragma_c_code_and_clauses1.m \
pragma_c_code_and_clauses2.m \
pragma_c_code_no_det.m \
@@ -85,6 +86,13 @@
%.err: %.m
if $(MC) $(ALL_MCFLAGS) --errorcheck-only $* > $*.err 2>&1; \
+ then false; else true; fi
+
+# We need a hard-coded rule for polymorphic_unification because we need to
+# do more than error check it: the error case we are checking for only
+# gets caught during polymorphism.
+polymorphic_unification.err: polymorphic_unification.m
+ if $(MC) $(ALL_MCFLAGS) polymorphic_unification > polymorphic_unification.err 2>&1; \
then false; else true; fi
# Some tests have more than one possible valid output, so
cvs diff: polymorphic_unification.err_exp is a new entry, no comparison available
cvs diff: polymorphic_unification.m is a new entry, no comparison available
--------------------------------------------------------------
New file: polymorphic_unification.m:
:- module polymorphic_unification.
:- interface.
:- import_module io.
:- pred main(io__state::di, io__state::uo) is det.
:- implementation.
main -->
[].
:- import_module list.
:- pred p(T, T).
:- mode p(in, list_skel->dead).
p(X, X).
--------------------------------------------------------------
New file: polymorphic_unification.err_exp:
Software error: Sorry, not implemented: polymorphic unification in mode other than (in, in)
Stack dump not available in this grade.
--------------------------------------------------------------
dgj
--
David Jeffery (dgj at cs.mu.oz.au) | Marge: Did you just call everyone "chicken"?
PhD student, | Homer: Noooo. I swear on this Bible!
Dept. of Comp. Sci. & Soft. Eng.| Marge: That's not a Bible; that's a book of
University of Melbourne | carpet samples!
Australia | Homer: Ooooh... Fuzzy.
More information about the developers
mailing list