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

David Glen JEFFERY dgj at cs.mu.OZ.AU
Mon Nov 30 17:27:01 AEDT 1998


On 30-Nov-1998, Warwick Harvey <wharvey at cs.monash.edu.au> wrote:
> 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
> +                       },

I think you have the "then and the "else" cases around the wrong way here.

> +                       { 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
> +                       },

Ditto.

Otherwise it is OK.


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