diff --git a/compiler/recompilation_version.m b/compiler/recompilation_version.m index cb8bf7337..662a1d9f5 100644 --- a/compiler/recompilation_version.m +++ b/compiler/recompilation_version.m @@ -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) diff --git a/tests/recompilation/TESTS b/tests/recompilation/TESTS index 179537aa1..0681f762c 100755 --- a/tests/recompilation/TESTS +++ b/tests/recompilation/TESTS @@ -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 \ diff --git a/tests/recompilation/change_func_r.err_exp.2 b/tests/recompilation/change_func_r.err_exp.2 new file mode 100644 index 000000000..86b2c0fd1 --- /dev/null +++ b/tests/recompilation/change_func_r.err_exp.2 @@ -0,0 +1,2 @@ +Recompiling module `change_func_r': + function `change_func_r_2:changed_func/1' was modified. diff --git a/tests/recompilation/change_func_r.exp.1 b/tests/recompilation/change_func_r.exp.1 new file mode 100644 index 000000000..d86bac9de --- /dev/null +++ b/tests/recompilation/change_func_r.exp.1 @@ -0,0 +1 @@ +OK diff --git a/tests/recompilation/change_func_r.exp.2 b/tests/recompilation/change_func_r.exp.2 new file mode 100644 index 000000000..d86bac9de --- /dev/null +++ b/tests/recompilation/change_func_r.exp.2 @@ -0,0 +1 @@ +OK diff --git a/tests/recompilation/change_func_r.m.1 b/tests/recompilation/change_func_r.m.1 new file mode 100644 index 000000000..41a3edbe6 --- /dev/null +++ b/tests/recompilation/change_func_r.m.1 @@ -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") + ). + diff --git a/tests/recompilation/change_func_r_2.err_exp.2 b/tests/recompilation/change_func_r_2.err_exp.2 new file mode 100644 index 000000000..dadc3aaac --- /dev/null +++ b/tests/recompilation/change_func_r_2.err_exp.2 @@ -0,0 +1,2 @@ +Recompiling module `change_func_r_2': + file `change_func_r_2.m' has changed. diff --git a/tests/recompilation/change_func_r_2.m.1 b/tests/recompilation/change_func_r_2.m.1 new file mode 100644 index 000000000..862c87cf9 --- /dev/null +++ b/tests/recompilation/change_func_r_2.m.1 @@ -0,0 +1,9 @@ +:- module change_func_r_2. + +:- interface. + +:- func changed_func(string) = string is det. + +:- implementation. + +changed_func(X) = X. diff --git a/tests/recompilation/change_func_r_2.m.2 b/tests/recompilation/change_func_r_2.m.2 new file mode 100644 index 000000000..a7ae8219c --- /dev/null +++ b/tests/recompilation/change_func_r_2.m.2 @@ -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.