for review: bug fix (conv_args_type_assign_set)
David Glen JEFFERY
dgj at cs.mu.OZ.AU
Fri Jan 16 16:39:33 AEDT 1998
Hi,
Can you please review this, Fergus?
Estimated hours taken: 1.5
Fix a bug, introduced by my typeclass changes, which caused typecheck.m to
abort with a software error for certain programs containing type errors.
compiler/typecheck.m:
Bring back conv_args_type_assign_set which was deleted during the
typeclass changes. Update conv_args_type_assign to apply the bindings
to the class constraints, and factor out some duplicate code between
conv_args_type_assign_set and convert_args_type_assign_set,
Change a call to convert_args_type_assign_set back to
conv_args_type_assign_set, so that it does not bomb out spuriously.
Index: compiler/typecheck.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/typecheck.m,v
retrieving revision 1.225
diff -u -r1.225 typecheck.m
--- typecheck.m 1998/01/13 10:13:52 1.225
+++ typecheck.m 1998/01/16 05:12:07
@@ -1187,18 +1187,11 @@
convert_args_type_assign_set([], []).
convert_args_type_assign_set(
- [args(TypeAssign0, Args, Constraints0)|ArgTypeAssigns],
+ [ArgTypeAssign|ArgTypeAssigns],
[TypeAssign | TypeAssigns]) :-
+ ArgTypeAssign = args(_, Args, _),
( Args = [] ->
- type_assign_get_typeclass_constraints(TypeAssign0,
- OldConstraints),
- type_assign_get_type_bindings(TypeAssign0, Bindings),
- apply_rec_subst_to_constraints(Bindings, Constraints0,
- Constraints),
-
- list__append(Constraints, OldConstraints, NewConstraints),
- type_assign_set_typeclass_constraints(TypeAssign0,
- NewConstraints, TypeAssign)
+ convert_args_type_assign(ArgTypeAssign, TypeAssign)
;
% this should never happen, since the arguments should
% all have been processed at this point
@@ -1206,10 +1199,27 @@
),
convert_args_type_assign_set(ArgTypeAssigns, TypeAssigns).
-:- pred conv_args_type_assign(pair(type_assign, list(type)), type_assign).
-:- mode conv_args_type_assign(in, out) is det.
+:- pred conv_args_type_assign_set(args_type_assign_set, type_assign_set).
+:- mode conv_args_type_assign_set(in, out) is det.
+
+ % Same as conv_args_type_assign_set, but does not abort when the args
+ % are empty
+conv_args_type_assign_set([], []).
+conv_args_type_assign_set([X|Xs], [Y|Ys]) :-
+ convert_args_type_assign(X, Y),
+ conv_args_type_assign_set(Xs, Ys).
+
+:- pred convert_args_type_assign(args_type_assign, type_assign).
+:- mode convert_args_type_assign(in, out) is det.
+
+convert_args_type_assign(args(TypeAssign0, _, Constraints0), TypeAssign) :-
+ type_assign_get_typeclass_constraints(TypeAssign0, OldConstraints),
+ type_assign_get_type_bindings(TypeAssign0, Bindings),
+ apply_rec_subst_to_constraints(Bindings, Constraints0, Constraints),
-conv_args_type_assign(TypeAssign - _ArgTypes, TypeAssign).
+ list__append(Constraints, OldConstraints, NewConstraints),
+ type_assign_set_typeclass_constraints(TypeAssign0,
+ NewConstraints, TypeAssign).
:- pred typecheck_var_has_arg_type(var,
args_type_assign_set, args_type_assign_set,
@@ -3599,7 +3609,7 @@
report_mismatched_args(Mismatches, yes, VarSet, Context)
;
- { convert_args_type_assign_set(ArgsTypeAssignSet,
+ { conv_args_type_assign_set(ArgsTypeAssignSet,
TypeAssignSet) },
%
love and cuddles,
dgj
--
David Jeffery (dgj at cs.mu.oz.au) | Marge: Did you just call everyone "chicken"?
MEngSc student, | Homer: Noooo. I swear on this Bible!
Department of Computer Science | 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