mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-14 05:12:33 +00:00
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:
@@ -564,16 +564,29 @@ item_is_unchanged(nothing(A), Item2) =
|
|||||||
( Item2 = nothing(A) -> yes ; no ).
|
( Item2 = nothing(A) -> yes ; no ).
|
||||||
|
|
||||||
item_is_unchanged(Item1, Item2) = Result :-
|
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,
|
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,
|
Item2 = pred_or_func(TVarSet2, _, ExistQVars2,
|
||||||
PredOrFunc, Name, TypesAndModes2, _Det2, Cond, Purity,
|
PredOrFunc, Name, TypesAndModes2, Det2, Cond, Purity,
|
||||||
Constraints2),
|
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,
|
pred_or_func_type_is_unchanged(TVarSet1, ExistQVars1,
|
||||||
TypesAndModes1, Constraints1, TVarSet2,
|
TypesAndModes1, Constraints1, TVarSet2,
|
||||||
ExistQVars2, TypesAndModes2, Constraints2)
|
ExistQVars2, TypesAndModes2, Constraints2)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ TESTS_SHOULD_SUCCEED="\
|
|||||||
add_instance_2_r \
|
add_instance_2_r \
|
||||||
add_type_nr \
|
add_type_nr \
|
||||||
change_class_r \
|
change_class_r \
|
||||||
|
change_func_r \
|
||||||
change_instance_r \
|
change_instance_r \
|
||||||
change_mode_r \
|
change_mode_r \
|
||||||
change_type_nr \
|
change_type_nr \
|
||||||
|
|||||||
2
tests/recompilation/change_func_r.err_exp.2
Normal file
2
tests/recompilation/change_func_r.err_exp.2
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
Recompiling module `change_func_r':
|
||||||
|
function `change_func_r_2:changed_func/1' was modified.
|
||||||
1
tests/recompilation/change_func_r.exp.1
Normal file
1
tests/recompilation/change_func_r.exp.1
Normal file
@@ -0,0 +1 @@
|
|||||||
|
OK
|
||||||
1
tests/recompilation/change_func_r.exp.2
Normal file
1
tests/recompilation/change_func_r.exp.2
Normal file
@@ -0,0 +1 @@
|
|||||||
|
OK
|
||||||
19
tests/recompilation/change_func_r.m.1
Normal file
19
tests/recompilation/change_func_r.m.1
Normal 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")
|
||||||
|
).
|
||||||
|
|
||||||
2
tests/recompilation/change_func_r_2.err_exp.2
Normal file
2
tests/recompilation/change_func_r_2.err_exp.2
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
Recompiling module `change_func_r_2':
|
||||||
|
file `change_func_r_2.m' has changed.
|
||||||
9
tests/recompilation/change_func_r_2.m.1
Normal file
9
tests/recompilation/change_func_r_2.m.1
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
:- module change_func_r_2.
|
||||||
|
|
||||||
|
:- interface.
|
||||||
|
|
||||||
|
:- func changed_func(string) = string is det.
|
||||||
|
|
||||||
|
:- implementation.
|
||||||
|
|
||||||
|
changed_func(X) = X.
|
||||||
12
tests/recompilation/change_func_r_2.m.2
Normal file
12
tests/recompilation/change_func_r_2.m.2
Normal 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.
|
||||||
Reference in New Issue
Block a user