mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-23 05:13:48 +00:00
Estimated hours taken: 10 Fix a code generator abort reported by Stephane Marie <stephane.marie@detexis.thomson-csf.com>. The bug was in the code to work out the instmap after a deconstruction unification with complicated sub-unifications. The instmap_delta for the unification contained only the bindings for the first argument for which a new variable was created. The test case now gives an error during mode analysis rather than a code generator abort (for unification procedures of imported types) or a mode error during unique mode analysis (for local types). compiler/modes.m: compiler/modecheck_call.m: compiler/modecheck_unify.m: Simplify the code to handle extra goals by not attempting to bodge together the instmap after the main goal. Instead, the code now creates the extra unifications and rechecks the goal with the unifications added. compiler/mode_info.m: Add a field to say whether we are reprocessing a goal after adding extra goals. Abort if the reprocessing adds more extra goals. The `may_changed_called_proc' field is now separate from the `how_to_check_goal' field. This is used to avoid repeating the search for the best procedure when rerunning mode analysis after adding the extra goals. compiler/modecheck_unify.m: Removed predicate unify_vars - it is no longer used. compiler/unify_proc.m: Call module_info_remove_predid if there are mode errors in a unification procedure to avoid spurious determinism errors. tests/hard_coded/Mmakefile: tests/hard_coded/partial_implied_mode.m: tests/hard_coded/partial_implied_mode.err_exp: Test case. It would be nicer if the error message pointed to the unification which caused the unification procedure to be created, rather than the type declaration in the interface file.
44 lines
1.4 KiB
Mathematica
44 lines
1.4 KiB
Mathematica
% This is a test for partially implied modes where the overbound
|
|
% term is partially instantiated. This really shouldn't be an error,
|
|
% and won't be with the alias tracking mode checker. It's difficult
|
|
% to make this program legal with the current mode checker without
|
|
% disallowing construction of partially instantiated terms.
|
|
%
|
|
% The reason partial_implied_mode2.m has to be a separate module
|
|
% is because unification procedures for local types have unique mode
|
|
% analysis run on them (although it's really not necessary).
|
|
% For local types, the code generator abort did not happen
|
|
% because unique_modes reported a mode error.
|
|
%
|
|
% Mercury rotd-1999-05-08 aborted during code generation on this
|
|
% test case.
|
|
:- module partial_implied_mode.
|
|
|
|
:- interface.
|
|
|
|
:- import_module map, list, partial_implied_mode2.
|
|
|
|
:- type quantitiesdico == map(quantity_key, physic_quantity).
|
|
|
|
:- pred search_quantitykey_1pin(pin, list(quantity_key),
|
|
quantitiesdico, quantity_key).
|
|
:- mode search_quantitykey_1pin(in, in, in, out) is det.
|
|
|
|
:- implementation.
|
|
|
|
:- import_module require.
|
|
|
|
search_quantitykey_1pin(PIN, [CUR_K|L], QTY_DICO, K) :-
|
|
(
|
|
map__lookup(QTY_DICO, CUR_K,
|
|
physic_quantity(PIN, _SYN, absol(_MEAS, _TBS)))
|
|
->
|
|
K = CUR_K
|
|
;
|
|
search_quantitykey_1pin(PIN, L, QTY_DICO, K)
|
|
).
|
|
search_quantitykey_1pin(_, [], _, _) :-
|
|
error(
|
|
"search_quantitykey_1pin : no such absolute quantity in the list").
|
|
|