[m-dev.] for review: polymorphic unification not (in, in)

Warwick Harvey wharvey at cs.monash.edu.au
Mon Nov 30 17:00:37 AEDT 1998


DJ wrote:
> 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.
[...]

This change does not output any context information.  Locating the source of 
the problem is therefore not straightforward.  :-(

So I present the following diff for review:

Estimated hours taken: 0.5

compiler/polymorphism.m:
	Include a context in the error message output when polymorphic
	unification is attempted with a non-ground instantiation.

Index: polymorphism.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/polymorphism.m,v
retrieving revision 1.156
diff -u -r1.156 polymorphism.m
--- polymorphism.m      1998/11/20 04:08:48     1.156
+++ polymorphism.m      1998/11/30 05:56:25
@@ -949,10 +949,28 @@
                                error("polymorphism.m: can't find 
`builtin:unify/2'")
                        },
                        { 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)") },
+                       { mode_is_fully_input(ModuleInfo, XMode) ->
+                               goal_info_get_context(GoalInfo, GoalContext),
+                               term__context_file(GoalContext, FileName),
+                               term__context_line(GoalContext, LineNumber),
+                               string__format("%s:%03d: Sorry, not 
implemented: polymorphic unification in mode other than (in, in)",
+                                               [s(FileName), i(LineNumber)],
+                                               ErrorMsg),
+                               error(ErrorMsg)
+                       ;
+                               true
+                       },
+                       { mode_is_fully_input(ModuleInfo, YMode) ->
+                               goal_info_get_context(GoalInfo, GoalContext),
+                               term__context_file(GoalContext, FileName),
+                               term__context_line(GoalContext, LineNumber),
+                               string__format("%s:%03d: Sorry, not 
implemented: polymorphic unification in mode other than (in, in)",
+                                               [s(FileName), i(LineNumber)],
+                                               ErrorMsg),
+                               error(ErrorMsg)
+                       ;
+                               true
+                       },
                        { hlds_pred__in_in_unification_proc_id(ProcId) },
                        { map__lookup(TypeInfoMap, TypeVar, TypeInfoLocn) },
                        { SymName = unqualified("unify") },





More information about the developers mailing list