Files
mercury/tests/term/existential_error1.m
Zoltan Somogyi 251ab8cce5 Don't treat .m files as substitutes for .opt files.
compiler/write_deps_file.m:
    When trying to check for the existence of .opt files, whether alone
    or together with .trans_opt files, do not consider a .m file as
    an acceptable substitute. Delete the option that can ask for this
    behavior.

compiler/globals.m:
    Delete ie_src as a kind of search for source files, since the change
    to write_deps_file.m deletes its only use.

compiler/generate_dep_d_files.m:
compiler/handle_options.m:
    Conform to the changes above.

tests/term/existential_error1.trans_opt_exp:
    Update the expected output of this test case, because the change
    in write_deps_file.m causes the compiler to get a library predicate's
    termination info from a .opt file instead of a .trans_opt file,
    and it happens to be different

tests/term/existential_error1.m:
    Document the reason for this difference.

tests/valid/Mmake.valid.common:
tests/warnings/Mmakefile:
    The valid_seq/opt_det_warn and warnings/inst_with_no_type test cases
    both specify --intermodule-optimization. Before this diff, the .opt file
    did not get built, but this was not an issue for the following reasons.

    - opt_det_warn tests for the *absence* of any message about something
      in the .opt file, while inst_with_no_type tests for a type definition
      in the implementation section of the helper module being invisible
      outside its module. Both tests are much easier to pass if you do not
      actually read the .opt file.

    - The generation of the warning message about the .opt file not being
      available was suppressed by the fact that the helper module's *source*
      file *was* available.

    Since the compiler now generates this warning message, so add
    mmake rules to force the helper modules' .opt files to be built
    before the compilation of the main modules.

tests/valid_seq/Mmakefile:
    Define some mmake vars that looked like they should help with
    those additional rules, but it seems, they don't.

    Add an XXX about a possible problem.

    Delete an XXX that is no longer relevant.

    Delete a commented out duplicate of an mmakefile entry.
2024-11-15 14:48:00 +11:00

59 lines
2.6 KiB
Mathematica

%---------------------------------------------------------------------------%
% vim: ts=4 sw=4 et ft=mercury
%---------------------------------------------------------------------------%
%
% Regression test for term_norm.m
% Symptom: "Software Error: Unmatched lists in functor_norm_filter_args."
% This was caused by the list of counted arguments in the weight table
% differing from the list of arguments the termination analyser provided
% when it called functor norm. The code that constructed the weight table
% was ignoring type_infos when constructing the list of counted arguments.
%
%---------------------------------------------------------------------------%
%
% This test case happens to also expose another issue about intermodule
% optimization.
%
% Whether the deconstruct_univ predicate below terminates or not is determined
% entirely by whether private_builtin.typed_unify terminates or not. However,
% private_builtin.opt and private_builtin.trans_opt in the library directory
% disagree about this: the .opt file gives typed_unify's termination status
% as can_loop, while .trans_opt gives it as cannot_loop. (The difference
% is that the compiler knows that a predicate that typed_unify calls,
% type_desc.type_of/1, terminates only when it has access to type_desc.opt.)
%
% Until 15 Nov 2024, the code of the get_plain_trans_opt_deps predicate in
% write_deps_file.m had code to ignore a module's .opt file and pay attention
% only to its .trans_opt file *if* the module's source file exists.
% (This behavior was present when this predicate was originally added
% to the compiler on 6 Jan 1998, though the predicate was then named
% get_both_opt_deps, and it was in modules.m.) The .trans_opt_exp file
% therefore had deconstruct_univ's termination status as cannot_loop.
% Since we now pay attention to modules' .opt files whether or not their
% source files are reachable, its expected status is now can_loop.
%
% Ideally, if we have access to both the .opt and the .trans_opt file
% of a module, we should pay attention to termination information
% in only the .trans_opt file, since it incorporates information
% not just from that module's .opt file, but other modules' .opt files
% as well. However, we do not (yet) do that.
%
%---------------------------------------------------------------------------%
:- module existential_error1.
:- interface.
:- type univ
---> some [T] univ_cons(T).
:- pred deconstruct_univ(univ::in, T::out) is semidet.
:- implementation.
deconstruct_univ(Univ, T) :-
Univ = univ_cons(T0),
private_builtin.typed_unify(T0, T).
:- end_module existential_error1.