Fix a bug in my last change.

Estimated hours taken: 0.5

Fix a bug in my last change.

compiler/recompilation_version.m:
	The log message for my last change said:
		"Ignore the determinism on a predicate declaration
		when checking whether it has changed. recompilation_version.m
		splits combined predicate and mode declarations before checking
		whether the predicate's declarations have changed. The problem
		only occurred if a predicate with a separate mode declaration
		also had a determinism annotation on the `:- pred' declaration."

	For function declarations, a determinism declaration with no
	modes means use the default modes. These aren't split out into
	a separate declaration, so the determinism on a function type
	declaration can't be ignored here.

tests/recompilation/TESTS:
tests/recompilation/changed_func_r*:
	Test case.
This commit is contained in:
Simon Taylor
2001-11-05 09:40:03 +00:00
parent d670b5bf58
commit efdfcdcb48
9 changed files with 66 additions and 6 deletions

View File

@@ -564,16 +564,29 @@ item_is_unchanged(nothing(A), Item2) =
( Item2 = nothing(A) -> yes ; no ).
item_is_unchanged(Item1, Item2) = Result :-
% Ignore the determinism -- the modes and determinism should
% have been split into a separate declaration. This case
% can only happen if this was not a combined predicate and
% mode declaration. XXX We should warn about this somewhere.
Item1 = pred_or_func(TVarSet1, _, ExistQVars1, PredOrFunc,
Name, TypesAndModes1, _Det1, Cond, Purity, Constraints1),
Name, TypesAndModes1, Det1, Cond, Purity, Constraints1),
(
Item2 = pred_or_func(TVarSet2, _, ExistQVars2,
PredOrFunc, Name, TypesAndModes2, _Det2, Cond, Purity,
PredOrFunc, Name, TypesAndModes2, Det2, Cond, Purity,
Constraints2),
% For predicates, ignore the determinism -- the modes and
% determinism should have been split into a separate
% declaration. This case can only happen if this was
% not a combined predicate and mode declaration
% (XXX We should warn about this somewhere).
% For functions a determinism declaration but no modes
% implies the default modes. The default modes are
% added later by make_hlds.m, so they won't have been
% split into a separate declaration here.
(
PredOrFunc = function,
Det1 = Det2
;
PredOrFunc = predicate
),
pred_or_func_type_is_unchanged(TVarSet1, ExistQVars1,
TypesAndModes1, Constraints1, TVarSet2,
ExistQVars2, TypesAndModes2, Constraints2)

View File

@@ -9,6 +9,7 @@ TESTS_SHOULD_SUCCEED="\
add_instance_2_r \
add_type_nr \
change_class_r \
change_func_r \
change_instance_r \
change_mode_r \
change_type_nr \

View File

@@ -0,0 +1,2 @@
Recompiling module `change_func_r':
function `change_func_r_2:changed_func/1' was modified.

View File

@@ -0,0 +1 @@
OK

View File

@@ -0,0 +1 @@
OK

View File

@@ -0,0 +1,19 @@
:- module change_func_r.
:- interface.
:- import_module io.
:- pred main(io__state::di, io__state::uo) is det.
:- implementation.
:- import_module change_func_r_2, std_util.
main -->
( { semidet_succeed, Str = changed_func("OK\n") } ->
io__write_string(Str)
;
io__write_string("failed\n")
).

View File

@@ -0,0 +1,2 @@
Recompiling module `change_func_r_2':
file `change_func_r_2.m' has changed.

View File

@@ -0,0 +1,9 @@
:- module change_func_r_2.
:- interface.
:- func changed_func(string) = string is det.
:- implementation.
changed_func(X) = X.

View File

@@ -0,0 +1,12 @@
:- module change_func_r_2.
:- interface.
:- func changed_func(string) = string is semidet.
:- implementation.
:- import_module std_util.
changed_func(X) = X :-
semidet_succeed.