[m-rev.] fix lcc type errors in hlc grades

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Aug 18 01:16:33 AEST 2003


On 18-Aug-2003, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> I tried the following patch, which defines just the comparison predicate,
> but it triggered a bug in the compiler:
> 
> 	Uncaught Mercury exception:
> 	Software Error: type error in pred call: no matching pred
...
> I guess until that bug is fixed (and installed everywhere,
> to avoid bootstrapping issues) I'll have to stick with defining
> both of them:

Sorry, I spoke too soon.  Defining both didn't help.
The problem was actually that I had defined the comparison predicate
with the wrong type for the arguments (I was using time_t rather than
time_t_rep).  Still, the Mercury compiler ought to report
a proper error message, rather than throwing an exception.

Here's the corrected version of the relative diff which defines
just the comparison predicate and uses time_t_rep for its argument types.

--- time.m.old	Mon Aug 18 00:50:45 2003
+++ time.m	Mon Aug 18 01:12:08 2003
@@ -208,8 +208,14 @@
 %
 :- type time_t ---> time_t(time_t_rep).
 
-:- type time_t_rep ---> time_t_rep(c_pointer).
-:- pragma foreign_type("C", time_t_rep, "time_t").
+:- type time_t_rep ---> time_t_rep(c_pointer) ; dummy.
+:- pragma foreign_type("C", time_t_rep, "time_t")
+	where comparison is compare_time_t_reps.
+
+:- pred compare_time_t_reps(comparison_result::uo,
+		time_t_rep::in, time_t_rep::in) is det.
+compare_time_t_reps(Result, X, Y) :-
+	compare(Result, difftime(time_t(X), time_t(Y)), 0.0).
 
 %-----------------------------------------------------------------------------%
 

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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