for review: improve handling of pred_consts (was Re: [m-rev.] diff: fix accumulator test case failure)
Simon Taylor
stayl at cs.mu.OZ.AU
Tue Jul 10 20:46:55 AEST 2001
I've committed this now.
Simon.
Estimated hours taken: 4
Use pred_const cons_ids in the unify_rhs field for constructions
of higher-order terms. Previously there would be a `cons(sym_name, arity)'
cons_id in the `unify_rhs', and a pred_const in the `unification'.
This avoids multiple calls to get_pred_id_and_proc_id, and is more
consistent with how other cons_ids are handled.
compiler/post_typecheck.m:
Find the pred_const cons_id for constructions of higher-order terms.
Make sure the sym_name field of a call goal is fully module qualified.
compiler/higher_order.m:
compiler/lambda.m:
Use `pred_const' rather than `cons(sym_name, arity)' in the
`unify_rhs' of constructions of higher-order terms.
compiler/polymorphism.m:
compiler/modecheck_unify.m:
Change the interface of polymorphism__convert_pred_to_lambda_goal
to reflect the fact that the pred_proc_id of the higher-order term
has already been computed by post_typecheck.m.
compiler/purity.m:
Don't attempt to resolve overloading if there were type errors.
If the type inference iteration limit was exceeded the code
to resolve overloading of higher-order terms in post_typecheck.m
can abort. This occurred with tests/invalid/type_inf_loop.m.
compiler/hlds_goal.m:
Remove documentation about the restrictions on cons_ids
in a unify_rhs, since they no longer apply.
compiler/intermod.m:
Remove code duplicated from post_typecheck.m.
compiler/hlds_data.m:
Add a comment that code_addr_const cons_ids are no longer
used (they are left over from an old method of constructing
type_ctor_infos).
compiler/hlds_out.m:
Don't abort on code_addr_consts in hlds_out__write_functor_cons_id.
This will avoid problems if anyone decides to start using
code_addr_consts again.
tests/invalid/Mmakefile:
tests/invalid/aditi_update_errors.m:
tests/invalid/aditi_update_derived_relation.{m,err_exp}:
Separate out parts of aditi_update_errors.m which
were no longer being tested because post_typecheck
is no longer run when there are type errors.
tests/invalid/aditi_update_errors.err_exp:
tests/invalid/aditi_update_mode_errors.err_exp:
Update the expected output.
--- hlds_out.m 2001/07/10 06:31:12 1.1
+++ hlds_out.m 2001/07/10 06:33:36
@@ -2113,8 +2113,10 @@
list__length(ArgVars)),
ArgVars, VarSet, ModuleInfo, AppendVarnums)
;
- { ConsId = code_addr_const(_, _) },
- { error("hlds_out__write_functor_cons_id: code_addr_const") }
+ { ConsId = code_addr_const(PredId, ProcId) },
+ io__write_string("code_addr_const("),
+ hlds_out__write_pred_proc_id(ModuleInfo, PredId, ProcId),
+ io__write_string(")")
;
{ ConsId = type_ctor_info_const(Module, Name, Arity) },
io__write_string("type_ctor_info("""),
--- intermod.m 2001/07/09 16:33:15 1.1
+++ intermod.m 2001/07/09 16:36:40
@@ -446,28 +446,8 @@
DoWrite) -->
intermod__traverse_list_of_goals(Goals0, Goals, DoWrite).
-intermod__traverse_goal(
- call(PredId0, B, Args, D, MaybeUnifyContext, PredName0) - Info,
- call(PredId, B, Args, D, MaybeUnifyContext, PredName) - Info, DoWrite)
- -->
- %
- % Fully module-qualify the pred name
- %
- intermod_info_get_module_info(ModuleInfo),
- intermod_info_get_var_types(VarTypes),
- intermod_info_get_tvarset(TVarSet),
- ( { invalid_pred_id(PredId0) } ->
- { map__apply_to_list(Args, VarTypes, ArgTypes) },
- { typecheck__resolve_pred_overloading(ModuleInfo, ArgTypes,
- TVarSet, PredName0, PredName1, PredId) }
- ;
- { PredId = PredId0 },
- { PredName1 = PredName0 }
- ),
- { unqualify_name(PredName1, UnqualPredName) },
- { module_info_pred_info(ModuleInfo, PredId, PredInfo) },
- { pred_info_module(PredInfo, PredModule) },
- { PredName = qualified(PredModule, UnqualPredName) },
+intermod__traverse_goal(Goal, Goal, DoWrite) -->
+ { Goal = call(PredId, _, _, _, _, _) - _ },
%
% Ensure that the called predicate will be exported.
--- post_typecheck.m 2001/07/09 16:33:15 1.1
+++ post_typecheck.m 2001/07/10 08:54:45
@@ -397,9 +397,17 @@
ArgTypes, TVarSet, PredName0, PredName, PredId)
;
PredId = PredId0,
- PredName = PredName0
+ get_qualified_pred_name(ModuleInfo, PredId, PredName)
).
+:- pred get_qualified_pred_name(module_info, pred_id, sym_name).
+:- mode get_qualified_pred_name(in, in, out) is det.
+
+get_qualified_pred_name(ModuleInfo, PredId, qualified(PredModule, PredName)) :-
+ module_info_pred_info(ModuleInfo, PredId, PredInfo),
+ pred_info_module(PredInfo, PredModule),
+ pred_info_name(PredInfo, PredName).
+
%-----------------------------------------------------------------------------%
post_typecheck__finish_aditi_builtin(_, _, _, _, aditi_call(_, _, _, _),
@@ -565,7 +573,7 @@
)
;
PredId = PredId0,
- SymName = SymName0
+ get_qualified_pred_name(ModuleInfo, PredId, SymName)
).
% Work out the modes of the arguments of a closure passed
Index: tests/invalid/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/invalid/Mmakefile,v
retrieving revision 1.91
diff -u -u -r1.91 Mmakefile
--- tests/invalid/Mmakefile 2001/06/27 08:34:51 1.91
+++ tests/invalid/Mmakefile 2001/07/10 09:25:10
@@ -14,6 +14,7 @@
MULTIMODULE_SOURCES= \
aditi_errors.m \
aditi_state_errors.m \
+ aditi_update_derived_relation.m \
aditi_update_errors.m \
aditi_update_mode_errors.m \
duplicate_instance_2.m \
@@ -138,6 +139,7 @@
MCFLAGS-aditi_errors = --aditi --no-intermodule-optimization
MCFLAGS-aditi_state_errors = --aditi --no-intermodule-optimization
+MCFLAGS-aditi_update_derived_relation = --aditi --no-intermodule-optimization
MCFLAGS-aditi_update_errors = --aditi --no-intermodule-optimization
MCFLAGS-aditi_update_mode_errors = --aditi --no-intermodule-optimization
MCFLAGS-any_mode = --infer-types
Index: tests/invalid/aditi_update_derived_relation.err_exp
===================================================================
RCS file: aditi_update_derived_relation.err_exp
diff -N aditi_update_derived_relation.err_exp
--- /dev/null Mon Apr 16 11:57:05 2001
+++ aditi_update_derived_relation.err_exp Tue Jul 10 20:30:26 2001
@@ -0,0 +1,3 @@
+aditi_update_derived_relation.m:018: In `aditi_insert' of predicate `aditi_update_derived_relation:q/3':
+aditi_update_derived_relation.m:018: error: the modified predicate is not a base relation.
+For more information, try recompiling with `-E'.
Index: tests/invalid/aditi_update_derived_relation.m
===================================================================
RCS file: aditi_update_derived_relation.m
diff -N aditi_update_derived_relation.m
--- /dev/null Mon Apr 16 11:57:05 2001
+++ aditi_update_derived_relation.m Tue Jul 10 19:28:27 2001
@@ -0,0 +1,21 @@
+:- module aditi_update_derived_relation.
+
+:- interface.
+
+:- import_module aditi.
+
+:- pred aditi_update_derived_relation(aditi__state::aditi_di,
+ aditi__state::aditi_uo) is det.
+
+:- implementation.
+
+:- import_module int.
+
+:- pred q(aditi__state::aditi_mui, int::out, int::out) is multi.
+:- pragma aditi(q/3).
+
+aditi_update_derived_relation -->
+ aditi_insert(q(_, 1, 2)).
+
+q(_, 1, 1).
+q(_, 2, 2).
Index: tests/invalid/aditi_update_errors.err_exp
===================================================================
RCS file: /home/mercury1/repository/tests/invalid/aditi_update_errors.err_exp,v
retrieving revision 1.4
diff -u -u -r1.4 aditi_update_errors.err_exp
--- tests/invalid/aditi_update_errors.err_exp 2000/04/14 08:39:15 1.4
+++ tests/invalid/aditi_update_errors.err_exp 2001/07/10 10:32:36
@@ -179,6 +179,4 @@
aditi_update_errors.m:173: expected type was `(aditi_bottom_up pred((aditi:state), int, int, (aditi:state), int, int))'.
aditi_update_errors.m:026: Error: no clauses for
aditi_update_errors.m:026: predicate `aditi_update_errors:anc/3'.
-aditi_update_errors.m:093: In `aditi_insert' of predicate `anc/3':
-aditi_update_errors.m:093: error: the modified predicate is not a base relation.
For more information, try recompiling with `-E'.
Index: tests/invalid/aditi_update_errors.m
===================================================================
RCS file: /home/mercury1/repository/tests/invalid/aditi_update_errors.m,v
retrieving revision 1.3
diff -u -u -r1.3 aditi_update_errors.m
--- tests/invalid/aditi_update_errors.m 2000/05/05 06:08:09 1.3
+++ tests/invalid/aditi_update_errors.m 2001/07/10 10:30:43
@@ -7,8 +7,8 @@
:- pred aditi_update_syntax(aditi__state::aditi_di,
aditi__state::aditi_uo) is det.
-:- pred aditi_update_derived_relation(aditi__state::aditi_di,
- aditi__state::aditi_uo) is det.
+
+
:- pred aditi_update_types(aditi__state::aditi_di,
aditi__state::aditi_uo) is det.
@@ -88,9 +88,9 @@
) },
aditi_bulk_modify(q/2, ModifyQ),
aditi_bulk_modify(func q/2, ModifyQ, foo).
+
+
-aditi_update_derived_relation -->
- aditi_insert(anc(_, 1, 2)).
aditi_update_types -->
aditi_insert(p(_, 1)),
Index: tests/invalid/aditi_update_mode_errors.err_exp
===================================================================
RCS file: /home/mercury1/repository/tests/invalid/aditi_update_mode_errors.err_exp,v
retrieving revision 1.4
diff -u -u -r1.4 aditi_update_mode_errors.err_exp
--- tests/invalid/aditi_update_mode_errors.err_exp 2000/05/05 06:08:09 1.4
+++ tests/invalid/aditi_update_mode_errors.err_exp 2001/07/10 09:44:24
@@ -23,15 +23,15 @@
aditi_update_mode_errors.m:105: In clause for predicate `aditi_update_mode_errors:aditi_update_modes11/2':
aditi_update_mode_errors.m:105: warning: variable `X0' occurs only once in this scope.
aditi_update_mode_errors.m:053: In clause for `aditi_update_modes1((aditi:aditi_di), (aditi:aditi_uo))':
-aditi_update_mode_errors.m:053: in argument 2 of the inserted tuple of `aditi_insert' of predicate `p/3':
+aditi_update_mode_errors.m:053: in argument 2 of the inserted tuple of `aditi_insert' of predicate `aditi_update_mode_errors:p/3':
aditi_update_mode_errors.m:053: mode error: variable `V_4' has instantiatedness `free',
aditi_update_mode_errors.m:053: expected instantiatedness was `ground'.
aditi_update_mode_errors.m:056: In clause for `aditi_update_modes2((aditi:aditi_di), (aditi:aditi_uo))':
-aditi_update_mode_errors.m:056: in argument 2 of the inserted tuple of `aditi_insert' of function `q/2':
+aditi_update_mode_errors.m:056: in argument 2 of the inserted tuple of `aditi_insert' of function `aditi_update_mode_errors:q/2':
aditi_update_mode_errors.m:056: mode error: variable `V_4' has instantiatedness `free',
aditi_update_mode_errors.m:056: expected instantiatedness was `ground'.
aditi_update_mode_errors.m:059: In clause for `aditi_update_modes3((aditi:aditi_di), (aditi:aditi_uo))':
-aditi_update_mode_errors.m:059: in argument 2 of `aditi_insert' of predicate `p/3':
+aditi_update_mode_errors.m:059: in argument 2 of `aditi_insert' of predicate `aditi_update_mode_errors:p/3':
aditi_update_mode_errors.m:059: mode error: variable `V_4' has instantiatedness `free',
aditi_update_mode_errors.m:059: expected instantiatedness was `ground'.
aditi_update_mode_errors.m:062: In clause for `aditi_update_modes4((aditi:aditi_di), (aditi:aditi_uo))':
@@ -43,19 +43,19 @@
aditi_update_mode_errors.m:065: mode error: variable `X' has instantiatedness `free',
aditi_update_mode_errors.m:065: expected instantiatedness was `ground'.
aditi_update_mode_errors.m:072: In clause for `aditi_update_modes6((aditi:aditi_di), (aditi:aditi_uo))':
-aditi_update_mode_errors.m:072: in argument 2 of `aditi_bulk_delete' of predicate `p/3':
+aditi_update_mode_errors.m:072: in argument 2 of `aditi_bulk_delete' of predicate `aditi_update_mode_errors:p/3':
aditi_update_mode_errors.m:072: mode error: variable `DeleteP' has instantiatedness `/* unique */(pred((free -> free), (free -> ground), (ground -> ground)) is nondet)',
aditi_update_mode_errors.m:072: expected instantiatedness was `(pred(in, out, out) is nondet)'.
aditi_update_mode_errors.m:078: In clause for `aditi_update_modes7((aditi:aditi_di), (aditi:aditi_uo))':
-aditi_update_mode_errors.m:078: in argument 2 of `aditi_bulk_delete' of function `q/2':
+aditi_update_mode_errors.m:078: in argument 2 of `aditi_bulk_delete' of function `aditi_update_mode_errors:q/2':
aditi_update_mode_errors.m:078: mode error: variable `DeleteQ' has instantiatedness `/* unique */(func((free -> free), (free -> ground)) = (ground -> ground) is nondet)',
aditi_update_mode_errors.m:078: expected instantiatedness was `(func(in, out) = out is nondet)'.
aditi_update_mode_errors.m:087: In clause for `aditi_update_modes8((aditi:aditi_di), (aditi:aditi_uo))':
-aditi_update_mode_errors.m:087: in argument 2 of `aditi_bulk_insert' of predicate `p/3':
+aditi_update_mode_errors.m:087: in argument 2 of `aditi_bulk_insert' of predicate `aditi_update_mode_errors:p/3':
aditi_update_mode_errors.m:087: mode error: variable `InsertP' has instantiatedness `/* unique */(pred((ground -> ground), (ground -> ground), (free -> ground)) is nondet)',
aditi_update_mode_errors.m:087: expected instantiatedness was `(pred(in, out, out) is nondet)'.
aditi_update_mode_errors.m:098: In clause for `aditi_update_modes9((aditi:aditi_di), (aditi:aditi_uo))':
-aditi_update_mode_errors.m:098: in argument 2 of `aditi_bulk_insert' of function `q/2':
+aditi_update_mode_errors.m:098: in argument 2 of `aditi_bulk_insert' of function `aditi_update_mode_errors:q/2':
aditi_update_mode_errors.m:098: mode error: variable `InsertQ' has instantiatedness `/* unique */(func((ground -> ground), (ground -> ground)) = (free -> ground) is nondet)',
aditi_update_mode_errors.m:098: expected instantiatedness was `(func(in, out) = out is nondet)'.
aditi_update_mode_errors.m:102: In clause for `aditi_update_modes10((aditi:aditi_di), (aditi:aditi_uo))':
@@ -69,11 +69,11 @@
aditi_update_mode_errors.m:105: have insts `free, unique(1), free',
aditi_update_mode_errors.m:105: which does not match any of the modes for function `int:+/2'.
aditi_update_mode_errors.m:115: In clause for `aditi_update_modes12((aditi:aditi_di), (aditi:aditi_uo))':
-aditi_update_mode_errors.m:115: in argument 2 of `aditi_bulk_modify' of predicate `p/3':
+aditi_update_mode_errors.m:115: in argument 2 of `aditi_bulk_modify' of predicate `aditi_update_mode_errors:p/3':
aditi_update_mode_errors.m:115: mode error: variable `ModifyP' has instantiatedness `/* unique */(pred((free -> free), (free -> ground), (free -> ground), (free -> free), (ground -> ground), (ground -> ground)) is semidet)',
aditi_update_mode_errors.m:115: expected instantiatedness was `(pred(in, out, out, unused, out, out) is nondet)'.
aditi_update_mode_errors.m:125: In clause for `aditi_update_modes13((aditi:aditi_di), (aditi:aditi_uo))':
-aditi_update_mode_errors.m:125: in argument 2 of `aditi_bulk_modify' of function `q/2':
+aditi_update_mode_errors.m:125: in argument 2 of `aditi_bulk_modify' of function `aditi_update_mode_errors:q/2':
aditi_update_mode_errors.m:125: mode error: variable `ModifyQ' has instantiatedness `/* unique */(pred((free -> free), (ground -> ground), (ground -> ground), (free -> free), (ground -> ground), (ground -> ground)) is nondet)',
aditi_update_mode_errors.m:125: expected instantiatedness was `(pred(in, out, out, unused, out, out) is nondet)'.
aditi_update_mode_errors.m:047: In clause for `anc((aditi:aditi_mui), out, out)':
--------------------------------------------------------------------------
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