Diff: Error message in assoc_list
Andrew Bromage
bromage at cs.mu.oz.au
Tue Jul 1 12:33:00 AEST 1997
G'day all.
Someone like to review this one?
Cheers,
Andrew Bromage
--------8<---CUT HERE---8<--------
Estimated hours taken: 0.4
Better reporting in assoc_list__from_corresponding_lists/3.
library/assoc_list.m:
Change the error message in assoc_list__from_corresponding_lists
so that it displays the types and lengths of the lists if they
differ in length.
library/Mmakefile:
library/assoc_list.nu.nl:
Add a Prolog version of the above which doesn't display the types,
make sure it's an overriding lib.
compiler/det_report.m:
compiler/lambda.m:
library/int.m:
Fix some spelling mistakes.
Index: compiler/det_report.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/det_report.m,v
retrieving revision 1.35
diff -u -r1.35 det_report.m
--- det_report.m 1997/05/05 11:16:50 1.35
+++ det_report.m 1997/06/30 05:44:38
@@ -682,7 +682,7 @@
{ CallUnifyContext = no },
prog_out__write_context(Context),
io__write_string(
- " Some wierd unification (or explicit call to `__Unify__'?) ")
+ " Some weird unification (or explicit call to `__Unify__'?) ")
)
;
(
Index: compiler/lambda.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/lambda.m,v
retrieving revision 1.27
diff -u -r1.27 lambda.m
--- lambda.m 1997/05/26 17:04:14 1.27
+++ lambda.m 1997/06/30 06:02:52
@@ -230,7 +230,7 @@
Var = Var0,
UniModes = UniModes0
;
- error("polymorphism__transform_lambda: wierd unification")
+ error("polymorphism__transform_lambda: weird unification")
),
% Optimize a special case: replace
Index: library/Mmakefile
===================================================================
RCS file: /home/staff/zs/imp/mercury/library/Mmakefile,v
retrieving revision 1.5
diff -u -r1.5 Mmakefile
--- Mmakefile 1997/06/16 13:35:26 1.5
+++ Mmakefile 1997/07/01 02:01:42
@@ -65,12 +65,12 @@
NU_LIBRARY_NOS = \
io.nu.no require.nu.no std_util.nu.no string.nu.no term_io.nu.no \
int.nu.no float.nu.no char.nu.no mercury_builtin.nu.no
-NU_OVERRIDING_LIBRARY_NOS = map.nu.no
+NU_OVERRIDING_LIBRARY_NOS = map.nu.no assoc_list.nu.no
NU_LIBRARY_QLS = \
io.nu.ql require.nu.ql std_util.nu.ql string.nu.ql term_io.nu.ql \
int.nu.ql float.nu.ql char.nu.ql mercury_builtin.nu.ql sp_lib.ql
-NU_OVERRIDING_LIBRARY_QLS = map.nu.ql
+NU_OVERRIDING_LIBRARY_QLS = map.nu.ql assoc_list.nu.ql
#-----------------------------------------------------------------------------#
Index: library/assoc_list.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/library/assoc_list.m,v
retrieving revision 1.4
diff -u -r1.4 assoc_list.m
--- assoc_list.m 1996/04/16 06:08:31 1.4
+++ assoc_list.m 1997/07/01 02:12:39
@@ -64,7 +64,7 @@
:- implementation.
-:- import_module require, set.
+:- import_module require, set, string.
assoc_list__reverse_members([], []).
assoc_list__reverse_members([K - V | KVs], [V - K | VKs]) :-
@@ -74,7 +74,25 @@
( assoc_list__from_corresponding_2(Ks, Vs, KVs0) ->
KVs = KVs0
;
- error("assoc_list__from_corresponding_lists: lists have different lengths.")
+ KeyType = type_name(type_of(Ks)),
+ list__length(Ks, KeyLength),
+ string__int_to_string(KeyLength, KeyLengthString),
+ ValueType = type_name(type_of(Vs)),
+ list__length(Vs, ValueLength),
+ string__int_to_string(ValueLength, ValueLengthString),
+ string__append_list(
+ ["assoc_list__from_corresponding_lists: lists have different lengths.\n",
+ "\tKey list type: ",
+ KeyType,
+ "\n\tKey list length: ",
+ KeyLengthString,
+ "\n\tValue list type: ",
+ ValueType,
+ "\n\tValue list length: ",
+ ValueLengthString
+ ],
+ ErrorString),
+ error(ErrorString)
).
:- pred assoc_list__from_corresponding_2(list(K), list(V), assoc_list(K,V)).
Index: library/int.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/library/int.m,v
retrieving revision 1.43
diff -u -r1.43 int.m
--- int.m 1997/05/21 02:16:10 1.43
+++ int.m 1997/07/01 01:51:30
@@ -288,7 +288,7 @@
%-----------------------------------------------------------------------------%
% is/2 is replaced with `=' in the parser, but the following is useful
-% in case you should take the address of `is' or something wierd like that.
+% in case you should take the address of `is' or something weird like that.
% we use pragma(c_code) to avoid complaints about redefinition of is/2
% from the Prolog compilers.
New File: library/assoc_list.nu.nl
===================================================================
%---------------------------------------------------------------------------%
% Copyright (C) 1997 University of Melbourne.
% This file may only be copied under the terms of the GNU Library General
% Public License - see the file COPYING.LIB in the Mercury distribution.
%---------------------------------------------------------------------------%
%
% File: assoc_list.nu.nl.
% Main author: bromage.
%
% This file provides an implementation of assoc_list__from_corresponding_lists,
% for which the Mercury % version calls type_of/1 if the lookup fails, but
% type_of/1 is not available from Prolog.
%
%-----------------------------------------------------------------------------%
assoc_list__from_corresponding_lists(Ks, Vs, KVs) :-
( assoc_list__from_corresponding_2(Ks, Vs, KVs0) ->
KVs = KVs0
;
list__length(Ks, KeyLength),
string__int_to_string(KeyLength, KeyLengthString),
list__length(Vs, ValueLength),
string__int_to_string(ValueLength, ValueLengthString),
string__append_list(
["assoc_list__from_corresponding_lists: lists have different lengths.\n",
"\tKey list length: ",
KeyLengthString,
"\n\tValue list length: ",
ValueLengthString
],
ErrorString),
error(ErrorString)
).
More information about the developers
mailing list