mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-13 21:04:00 +00:00
Specifically, we now do three new checks:
BAD_DETISM: We now generate error messages for predicate declarations
that specify a determinism without also specifying argument modes.
BAD_PREDMODE: We now generate error messages for standalone mode declarations
for predicates whose predicate declaration includes modes for the arguments.
BAD_MODE_SECTION: We now generate error messages for standalone mode
declarations that are not in the same section as the predicate's (or
function's) type declaration.
compiler/hlds_pred.m:
Add a slot to the pred_sub_info. If the predicate is explicitly defined by
the user in the current module, this contains the id of the section that
contains its predicate declaration (for the BAD_MODE_SECTION check)
and whether that predicate declaration also had modes for the arguments
(for the BAD_PREDMODE check).
compiler/add_pred.m:
When adding adding new predicate declarations, perform the BAD_DETISM
check, and record the info needed for the BAD_PREDMODE and BAD_MODE_SECTION
checks.
When adding adding new mode declarations, perform the BAD_PREDMODE
and BAD_MODE_SECTION checks.
compiler/add_class.m:
compiler/add_mutable_aux_preds.m:
compiler/add_pragma_tabling.m:
compiler/add_pragma_type_spec.m:
compiler/add_solver.m:
compiler/add_special_pred.m:
compiler/check_typeclass.m:
compiler/dep_par_conj.m:
compiler/higher_order.m:
compiler/make_hlds_passes.m:
compiler/table_gen.m:
compiler/unused_args.m:
Conform to the changes above.
mdbcomp/builtin_modules.m:
Add a utility predicate for use by new code in add_pred.m.
compiler/comp_unit_interface.m:
compiler/goal_util.m:
compiler/prog_rename.m:
compiler/quantification.m:
deep_profiler/program_representation_utils.m:
library/calendar.m:
library/mutvar.m:
library/pretty_printer.m:
library/random.m:
library/set_ctree234.m:
library/solutions.m:
library/stream.string_writer.m:
profiler/globals.m:
tests/accumulator/nonrec.m:
tests/accumulator/out_to_in.m:
tests/declarative_debugging/library_forwarding.m:
tests/dppd/applast_impl.m:
tests/dppd/grammar_impl.m:
tests/dppd/regexp.m:
tests/dppd/transpose_impl.m:
tests/hard_coded/copy_pred.m:
tests/hard_coded/ho_func_default_inst.m:
tests/recompilation/unchanged_pred_nr_2.m.1:
tests/recompilation/unchanged_pred_nr_2.m.2:
tests/valid/det_switch.m:
tests/valid/inlining_bug.m:
Delete determinism declarations from predicate and function declarations
that have no argument mode information, since the BAD_DETISM check
now makes these errors.
tests/valid/two_pragma_c_codes.m:
Move some mode declarations to the right section, since the
BAD_MODE_SECTION check now generates an error for the old code.
tests/invalid/typeclass_bad_method_mode.{m,err_exp}:
New test case to test for the BAD_PREDMODE check.
tests/invalid/mode_decl_in_wrong_section.{m,err_exp}:
New test case to test for the BAD_MODE_SECTION check.
tests/invalid/bad_detism.err_exp:
Add an expected output for this old, but never enabled test case,
which tests for new check BAD_DETISM.
tests/invalid/Mmakefile:
Enable the new test cases.
tests/invalid/typeclass_dup_method_mode.m:
This test case used to have two bugs. One is now by itself in the new
typeclass_bad_method_mode.m test case, so modify it to contain only
the other (indistinguishable modes).
tests/invalid/func_errors.err_exp:
tests/invalid/tc_err1.err_exp:
tests/invalid/undef_lambda_mode.err_exp:
tests/invalid/undef_type_mode_qual.err_exp:
Expect an extra error message from the BAD_DETISM check.
45 lines
1.4 KiB
Mathematica
45 lines
1.4 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
%
|
|
% Regression test for an abort in code generation.
|
|
% When the actual type for a polymorphic argument is non-polymorphic,
|
|
% only the base_type_info is passed, avoiding the construction of
|
|
% a type_info. The problem was that the type of the type_info argument
|
|
% was being set to `mercury_builtin:base_type_info' rather than
|
|
% `type_info'. In the code to compute the type substitution in inlining,
|
|
% type_list_subsumes failed on the argument types, and no substitution
|
|
% was produced. code_util__cons_id_to_tag then aborted when asked to
|
|
% find the tag for a constructor of a variable type.
|
|
|
|
:- module inlining_bug.
|
|
|
|
:- interface.
|
|
|
|
:- pred calling_pred(int::in) is semidet.
|
|
|
|
:- implementation.
|
|
|
|
:- import_module int.
|
|
:- import_module list.
|
|
|
|
:- type my_pair(A)
|
|
---> pair(A, A).
|
|
|
|
calling_pred(_) :-
|
|
Plus1 =
|
|
(pred(Int0::in, IntPair::out) is det :-
|
|
IntPair = pair(Int0, Int0)
|
|
),
|
|
called_pred(Plus1, [1, 2, 3], [X | Ys]),
|
|
X = pair(2, 2),
|
|
Ys = [pair(3, 3), pair(4, 4)].
|
|
|
|
:- pred called_pred(pred(T, U), list(T), list(U)).
|
|
:- mode called_pred(pred(in, out) is det, in, out) is semidet.
|
|
:- pragma inline(called_pred/3).
|
|
|
|
called_pred(P, [A | As], [B | Bs]) :-
|
|
call(P, A, B),
|
|
list__map(P, As, Bs).
|