compiler/parse_type_defn.m:
As above.
tests/invalid/field_syntax_error.{m,err_exp}:
tests/invalid/types.{m,err_exp}:
Add an instance of each bug the diagnostics are for,
and test for the updated diagnostic text.
This allows to perform those checks for *all* foreign_procs,
not just the ones that get added to the HLDS.
compiler/add_foreign_proc.m:
Move the code that checks the bodies of foreign_procs for the
presence of type_info variables for existentially quantified
type variables here from typecheck.m and typecheck_errors.m.
Change the diagnostic's wording to match our new phraseology.
Record identifiers in a set, not a list, for faster membership tests,
since we now do even more of them.
compiler/foreign.m:
Provide a mechanism to return the identifiers not just in the
non-comment parts of foreign_procs, but the comment parts as well,
since add_foreign_proc.m now needs this functionality.
compiler/make_hlds_warn.m:
Conform to the change in foreign.m.
compiler/typecheck.m:
compiler/typecheck_errors.m:
Delete the code that was moved (in a modified form)
to add_foreign_proc.m.
compiler/ml_foreign_proc_gen.m:
Update a reference in a comment.
tests/invalid/exist_foreign_error.err_exp:
Expect the updated wording of the affected diagnostics,
and expect diagnostics for *all* the foreign_procs in the test,
regardless of which language they are for.
tests/invalid/exist_foreign_error.err_exp2:
tests/invalid/exist_foreign_error.err_exp3:
Delete these files, since the output they expect is now
in the .err_exp file.
tests/invalid/fp_dup_bug.err_exp2:
tests/invalid/fp_dup_bug.err_exp3:
tests/invalid/gh72_errors.err_exp2:
tests/invalid/gh72_errors.err_exp3:
Expect the updated wording of diagnostics affected by previous
changes (which updated the .err_exp files for C, not these for
Java and C#).
compiler/add_foreign_proc.m:
Use the agreed wording *consistently* in the diagnostics
generated by this module.
Also, delete a call to the test for builtins that I recently
accidentally duplicated instead of just moving.
tests/invalid/foreign_proc_dup_var.err_exp:
tests/invalid/foreign_purity_mismatch.err_exp:
tests/invalid/fp_dup_bug.err_exp:
tests/invalid/pragma_qual_error.err_exp:
tests/warnings/foreign_singleton.err_exp:
tests/warnings/singleton_test.err_exp:
tests/warnings/warn_return.err_exp:
tests/warnings/warn_succ_ind.err_exp:
Expect the updated wording for all those diagnostics.
compiler/add_foreign_proc.m:
Perform several more kinds of checks on all foreign_procs,
not just on the foreign_procs that we end up adding to the HLDS.
These are
- the checks for whether the foreign_proc is for a builtin operation;
- the checks for repeated variables in the foreign_proc's argument list;
and
- the checks for purity mismatches between the foreign_proc
and the predicate/function it is for.
An unrelated change: simplify, and make much more direct, the logic
of the is_foreign_proc_for_this_backend predicate.
tests/invalid/foreign_proc_dup_var.err_exp:
tests/invalid/foreign_purity_mismatch.err_exp:
Expect error messages not just for C foreign_procs, but Java and C#
foreign_procs as well.
tests/invalid/foreign_proc_dup_var.err_exp2:
tests/invalid/foreign_proc_dup_var.err_exp3:
tests/invalid/foreign_purity_mismatch.err_exp2:
tests/invalid/foreign_purity_mismatch.err_exp3:
Delete these files, which used to hold the diagnostics for
Java and C# foreign_procs respectively.
compiler/make_hlds_warn.m:
When generating "did you mean" messages to add to warnings about
singleton variables, consider state variables in two separate ways.
- When figuring out what you could have meant with a singleton reference
that is a variable such as PredInfo, consider that the intended reference
*could* have been to a state variable (such as !.PredInfo).
- When figuring out what you could have meant with a singleton reference
that is a state variable reference as !.PredIfno or !:PredIfno, consider
that the intended reference *could* have been to another state variable
(such as !.PredInfo or !:PredInfo).
Stop passing around a parameter that, for some predicates, was *always*
set to the same value.
tests/invalid/undef_symbol.{m,err_exp}:
Extend this test case with code that (except for the types)
duplicates the motivating example for this change.
tests/invalid/bug278.err_exp:
tests/invalid/field_syntax_error.err_exp:
Expect the extra dym messages that we now generate.
compiler/foreign.m:
When returning the list of identifiers inside a foreign_proc's code,
ignore the contents of comments. This means that warnings about
variable names that occur in the foreign_proc's argument list
but do not occur in the foreign_proc's code cannot be shut up anymore
by mention the variable name in comments.
The "mostly" part is that typecheck.m still looks at the bodies
of foreign_procs without knowing about comments. Fixing that
will be part a future change.
NEWS.md:
Announce this breaking change.
compiler/fact_table_gen.m:
When we try to generate a foreign_proc's body for a fact table
but cannot do so due to the fact table file not being readable,
add a marker to the predicate that the fact table is for.
compiler/hlds_markers.m:
Update the documentation of the existing predicate marker
we use for this.
compiler/make_hlds_warn.m:
Do not warn about singleton variables in foreign_proc bodies
that are empty due to missing fact table files.
library/array.m:
library/io.file.m:
library/profiling_builtin.m:
library/stm_builtin.m:
library/table_builtin.m:
library/term_size_prof_builtin.m:
tests/invalid/erroneous_throw_promise.m:
tests/invalid/foreign_procs_exist_type.m:
tests/invalid/foreign_purity_mismatch.m:
tests/invalid/gh72_errors.m:
tests/invalid_purity/purity.m:
tests/valid/solv.m:
Shut up warnings about singletons in foreign_procs by adding a _ prefix
to the names of the relevant arguments, and delete the comments
that can no longer do that job.
tests/invalid/foreign_purity_mismatch.err_exp:
tests/invalid/gh72_errors.err_exp:
tests/invalid/gh72_errors.err_exp2:
tests/invalid/gh72_errors.err_exp3:
tests/invalid_purity/purity.err_exp:
Expect updated line numbers.
tests/warnings/warn_return.{m,err_exp}:
Extend this test case to test that
- we DO warn about return statements outside comments, but
- we DO NOT warn about return statements inside comments.
compiler/parse_goal.m:
As above.
tests/invalid/field_syntax_error.{m,err_exp}:
Extend this test case with a test of the new warning.
Document its old as well as its new parts.
compiler/mode_errors.m:
When generating diagnostics about code that is mode-incorrect
because it can be backtracked over, explicitly mention the possibility
that the culprit is a comma accidentally replaced by a period elsewhere.
compiler/options.m:
Turn --warn-non-contiguous-clauses on by default. This should provide
the context of any such typos.
NEWS.md:
Mention the change in options.m.
Fix existing typos.
tests/invalid/ho_unique_error.err_exp:
tests/invalid/io_in_ite_cond.err_exp:
tests/invalid/mostly_uniq_1.err_exp:
tests/invalid/mostly_uniq_2.err_exp:
tests/invalid/uniq_modes.err_exp:
tests/invalid/uniq_neg.err_exp:
Conform to the change in mode_errors.m.
tests/warnings/help_text.err_exp:
Conform to the change in options.m.
compiler/typecheck_error_undef.m:
When users try to use arithmetic operations, bitwise operations,
or comparisons (meaning functions such as '+' or '<<', or predicates
such as '<') without importing any of the modules that define those ops,
generate a diagnostic that explains this specific situation. Mercury
is unusual in requiring such imports, so novices need to have this
pointed out to them. Have these messages replace the less-specific
messages we used to generate in such situations.
Fix a persistent typo.
tests/invalid/int_ops.{m,err_exp}:
A new test case for the new diagnostics.
tests/invalid/Mmakefile:
Enable the new test case.
tests/invalid/multiply_star.err_exp:
Expect the diagnostic text, and stop expecting the "did you mean"
message that it replaces.
tests/invalid/multiply_star.err_exp[23]:
Delete these files. They existed only because different sets of imports
with different options yielded different "did you mean" suggestions,
and we don't have those anymore.
tests/invalid/multiply_star.m:
Update the descriptions of the deleted .err_exp[23] files.
tests/invalid/require_tailrec_2.err_exp3:
This test case asks for warnings only about non-tail *self* recursion.
Since 2025 aug 18, the compiler actually respects this. Update the
expected output for deep profiling grades to conform to this.
compiler/det_check_goal.m:
When reporting that a disjunction has more than one disjunct
that can succeed (which is an error if the disjunction is supposed
to be e.g. det or semidet), if the disjunct is actually a whole clause
in the source code, then mention that fact.
compiler/hlds_markers.m:
Define a goal feature that, when present, says "this goal used to be
a whole clause".
compiler/clause_to_proc.m:
Set this feature on clauses that we turn into disjuncts.
Make the predicate involved tail recursive.
compiler/saved_vars.m:
Conform to the change in hlds_markers.m.
tests/invalid/accidental_clause.{m,err_exp}:
Add this test case, which is a much-simplified version of the code
from an old post on m-users that motivated this change.
tests/invalid/Mmakefile:
Enable the new test case.
tests/invalid/not_a_switch.err_exp:
Expect the updated form of this diagnostic.
compiler/post_typecheck.m:
As above.
tests/invalid/bug184.err_exp:
tests/invalid/bug214.err_exp:
tests/invalid/typeclass_test_8.err_exp:
tests/invalid/unsatisfiable_constraint.err_exp:
Conform to the above change.
compiler/typecheck_error_undef.m:
As above.
tests/invalid/bad_field.{m,err_exp}:
A test case for this capability.
tests/invalid/Mmakefile:
Enable the new test case.
compiler/typecheck_error_overload.m:
When reporting type a type ambiguity that is itself an error
(as opposed to being problematic *only* because it increases
the number of type assigns needed), do NOT use terminology
that implies that the problem is the sheer number of ambiguities.
Indeed, the main test case of this code, bad_ambiguity_msg,
involves just one predicate name that has two matches,
which is the lowest possible level of ambiguity that
deserves an error message.
The old code used this bad terminology becaused it reused
the code of the function that reported exceededing the
ambiguity warning limit. Another effect of this bad reuse,
apart from the bad wording of the always-printed message,
was the addition of a verbose-only hint about the way to fix
the excessive ambiguity, which is totally misleading in this
situation.
In the absence of this reuse, we can now simplify the operation
of the code that generates warnings and errors about too much
overloading.
In some cases, eliminate some repetition in the diagnostic text.
tests/invalid/Mercury.options:
Specify the printing of verbose-only parts of diagnostics.
With this enabled, the inappropriateness of the reuse
would have been immediately apparent.
tests/invalid/bad_ambiguity_msg.err_exp:
Expect the updated wording. Do not expect a reminder about
any verbose-only part, since now there is none.
tests/invalid/coerce_ambig.{m,err_exp}:
Test for reporting not just one variable being ambiguous,
but also for two variables being ambiguous. (Together,
these exercise both paths through the relevant code.)
compiler/typecheck_error_unify.m:
As above.
compiler/hlds_error_util.m:
compiler/typecheck_error_util.m:
Export operations that are now needed by typecheck_error_unify.m.
To make this possible, carve some of those operations out of
other operations.
tests/invalid/ho_type_arity_bug.err_exp:
tests/invalid/missing_closure_arg.err_exp:
tests/invalid/nullary_ho_func_error.err_exp:
tests/invalid_nodepend/errors_2.err_exp:
tests/invalid_purity/impure_func_t5.err_exp:
tests/invalid_purity/impure_pred_t1.err_exp:
Expect the updated diagnostics.
compiler/file_util.m:
Define standard routines for reporting that we couldn't open a file
for either input or output. Rename the one other predicate in this file
that the compiler used for that purpose, so that its call sites
can be redirected to use one of the routines intended for this purpose.
Give these routines the ability to standardize path names (by removing
"./" prefixes from relative path names, and removing all directory names
from adsolute path names) if a new option is given.
compiler/options.m:
Add that (developer-only) option.
compiler/compile_target_code.m:
compiler/copy_util.m:
compiler/export.m:
compiler/llds_out_file.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_make_hlds.m:
compiler/mercury_compile_middle_passes.m:
compiler/mercury_compile_mlds_back_end.m:
compiler/mlds_to_c_file.m:
compiler/mlds_to_cs_file.m:
compiler/mlds_to_java_file.m:
compiler/module_cmds.m:
compiler/opt_deps_spec.m:
compiler/output_imports_graph.m:
compiler/passes_aux.m:
compiler/system_cmds.m:
compiler/write_deps_file.m:
compiler/xml_documentation.m:
Replace all call sites to the file_util.m predicates modified
by this diff. In many cases, it replaces duplicate copies of the
same code with a call. In some cases, redirect the error message
to the progress stream, where it belongs.
tests/invalid/Mercury.options:
tests/invalid/foreign_include_file_missing.err_exp3:
Compile the foreign_include_file_missing test case with the new option,
and add the expected output in C# grades, which (thanks to the option)
no longer includes the pathname of the test directory.
tests/invalid/foreign_include_file_missing.m:
Record what the new .err_exp3 file is for.
tests/warnings/help_text.err_exp:
Expect the new option.
compiler/direct_arg_in_out.m:
Add color to some overlooked diagnostics.
tests/invalid/gh72_errors.err_exp:
tests/invalid/gh72_errors.err_exp3:
Update these expected outputs for the change above, and for some
earlier changes.
tests/invalid/try_detism.err_exp2:
tests/warnings/warn_succ_ind.err_exp2:
Update these expected outputs for some earlier changes.
compiler/add_foreign_enum.m:
compiler/check_type_inst_mode_defns.m:
There used to be unnecessary differences between how we reported
foreign_enum and foreign_export_enum pragmas for non-enum du types.
Fir this by using the same code for reporting this problem for
both pragmas. Make this code use the best parts of each original approach.
tests/invalid/ee_invalid.err_exp:
tests/invalid/exported_foreign_enum.err_exp:
Expect the updated text.
compiler/write_error_spec.m:
When error_specs include blank lines, we used to output lines
of the form "filename:linenumber: ". Stop generating the final space.
compiler/parse_tree_out_misc.m:
Add a new version of an existing function.
tests/invalid/actual_more_expected.err_exp:
tests/invalid/ambiguous_overloading_error.err_exp:
tests/invalid/any_passed_as_ground.err_exp:
tests/invalid/anys_in_negated_contexts.err_exp:
tests/invalid/bad_ambiguity_msg.err_exp:
tests/invalid/bug150.err_exp:
tests/invalid/bug150_partial_color.err_exp:
tests/invalid/bug496.err_exp:
tests/invalid/det_atomic_goal_msgs.err_exp:
tests/invalid/det_errors.err_exp:
tests/invalid/det_errors_and_io.err_exp:
tests/invalid/det_errors_deep.err_exp:
tests/invalid/ho_default_func_1.err_exp:
tests/invalid/ho_default_func_3.err_exp:
tests/invalid/ho_default_func_4.err_exp:
tests/invalid/ho_type_mode_bug.err_exp:
tests/invalid/magicbox.err_exp:
tests/invalid/max_error_line_width.err_exp:
tests/invalid/mode_inf.err_exp:
tests/invalid/modes_erroneous.err_exp:
tests/invalid/no_ho_inst.err_exp:
tests/invalid/not_a_switch.err_exp:
tests/invalid/state_vars_test_1.err_exp:
tests/invalid/try_detism.err_exp:
tests/invalid/user_field_access_decl_override_1.err_exp:
tests/invalid_nodepend/errors_2.err_exp:
tests/warnings/ambiguous_overloading.err_exp:
tests/warnings/inconsistent_pred_order.err_exp:
tests/warnings/subtype_order.err_exp:
tests/warnings/test_tscp.err_exp:
Stop expecting a final space.
tests/invalid/illtyped_compare.err_exp2:
Add an expected output for target languages for which
unification pretests cast the input arguments to c_pointers,
not ints.
tests/invalid/pragma_c_code_dup_var.err_exp3:
tests/invalid/pragma_c_code_no_det.err_exp3:
tests/invalid/test_may_duplicate.err_exp3:
tests/invalid/test_may_export_body.err_exp3:
tests/invalid/try_detism.err_exp2:
tests/warnings/foreign_singleton.err_exp3:
Update these expected output files to expect color in diagnostics,
and (in some cases) updated wording as well.
tests/invalid_make_int/unbalanced.{m,int_err_exp}:
Move the tests/invalid_nodepend/unbalanced test case here,
since the diagnostics we are testing are reported when making
interface files.
tests/invalid_make_int/Mmakefile:
tests/invalid_nodepend/Mmakefile:
Conform to the move.
tests/warnings/Mmakefile:
Disable the unused_args_analysis test case in non-C grades,
because the test setup works only for C.
tests/invalid/bad_fact_table_decls.m:
tests/invalid/bad_fact_table_decls_[123]:
Add dummy fact table data files for this test case,
because mmc --make reports an error if they do not exist,
and stops looking for the errors that this test case
is intended to exercise.
tests/invalid/exist_foreign_error.err_exp3:
Update this expected output file to expect color in diagnostics.
tests/invalid/exported_foreign_enum.{m,err_exp}:
This test case was set up only for C grades. Change it to test
the same functionality in Java and C# grades as well, and simplify it
by using just one interface and implementation section each.
tests/invalid/bad_tscp.{m,err_exp}:
tests/invalid_make_int/bad_tscp.{m,int_err_exp}:
Move the bad_tscp test case from invalid to invalid_make_int,
because for a while now, the compiler has been reporting
the errors we are testing for when making interface files.
tests/invalid/Mercury.options:
tests/invalid/Mmakefile:
Stop referring to the moved test case.
tests/invalid_make_int/Mercury.options:
tests/invalid_make_int/Mmakefile:
Copy the references to the moved test case.
Add a missing module's (redundant_imports's) setup to Mercury.options.
The objective of this step is two-fold:
- to fix --inhibit-warnings, making it shut up all warning
and informational messages; and
- to ensure that it *stays* fixed, even when after new diagnostics
are added.
As part of this fix, this diff adds a whole bunch of new warning
options, in order to control the warnings that previously were
not controlled by any option. (There was no need for new
informational options.)
As it happens, we have long used severity_informational for messages
that did not report any information about the code being compiled,
but to report actions that the compiler was taking. Create a new
option category, oc_report, for the new options that now control
those diagnostics.
---------------------
compiler/error_spec.m:
Change severity_warning and severity_informational to take an option
as as argument. The semantics is that the diagnostic in which
the severity occurs is conditional on that option, meaning that
it is printed only if that option is set to "yes".
Delete the severity_conditional function symbol from the severity
type, since the mechanism just above handles its only use case.
Define subtypes to represent error_specs in a standard form.
compiler/error_sort.m:
Provide operations to convert error specs into their standard form.
Make the sorting operation itself operate on the standard form.
compiler/write_error_spec.m:
Convert error_specs to standard form before writing them out,
in order to avoid duplicating the code for their standardization.
Change the code that writes out error_specs to operate on the
standard form. Implement the test implicit in the warning and
and informational severities in this code.
compiler/error_util.m:
compiler/compiler_util.m:
Delete operations that do not make sense with the new severity type.
---------------------
compiler/options.m:
Add new options to control all the previously-uncontrolled
warning and informational messages.
NEWS.md:
Announce the *public* new options.
compiler/option_categories.m:
compiler/print_help.m:
Add the new option category, and fake-include it in the help text
and the user guide. (The inclusion is fake because none of the
options in the new category are user visible, meaning the section
containing them is not visible either.)
---------------------
compiler/det_infer_goal.m:
Start a severity warning diagnostic with "Warning:"
instead of "Error:".
compiler/mark_trace_goals.m:
Fix an incorrect error message.
compiler/purity.m:
Replace a correct/incorrect color pair with two inconsistent colors,
because there is a reasonable probability of each one being right.
---------------------
compiler/accumulator.m:
compiler/add_clause.m:
compiler/add_mode.m:
compiler/add_pragma.m:
compiler/add_pragma_tabling.m:
compiler/add_pred.m:
compiler/add_type.m:
compiler/check_module_interface.m:
compiler/check_type_inst_mode_defns.m:
compiler/check_typeclass.m:
compiler/color_schemes.m:
compiler/common.m:
compiler/convert_import_use.m:
compiler/convert_parse_tree.m:
compiler/dead_proc_elim.m:
compiler/det_check_proc.m:
compiler/det_check_switch.m:
compiler/det_infer_goal.m:
compiler/du_type_layout.m:
compiler/format_call_errors.m:
compiler/grab_modules.m:
compiler/hlds_call_tree.m:
compiler/inst_check.m:
compiler/introduce_parallelism.m:
compiler/make_hlds_error.m:
compiler/make_hlds_warn.m:
compiler/mark_tail_calls.m:
compiler/mark_trace_goals.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_make_hlds.m:
compiler/mode_errors.m:
compiler/modes.m:
compiler/module_qual.qual_errors.m:
compiler/opt_deps_spec.m:
compiler/options_file.m:
compiler/parse_goal.m:
compiler/post_term_analysis.m:
compiler/post_typecheck.m:
compiler/pre_typecheck.m:
compiler/purity.m:
compiler/read_modules.m:
compiler/recompilation.check.m:
compiler/simplify_goal.m:
compiler/simplify_goal_call.m:
compiler/simplify_goal_disj.m:
compiler/simplify_goal_ite.m:
compiler/split_parse_tree_src.m:
compiler/state_var.m:
compiler/stratify.m:
compiler/style_checks.m:
compiler/superhomogeneous.m:
compiler/table_gen.m:
compiler/term_constr_errors.m:
compiler/term_errors.m:
compiler/termination.m:
compiler/typecheck_clauses.m:
compiler/typecheck_error_overload.m:
compiler/typecheck_error_undef.m:
compiler/typecheck_errors.m:
compiler/typecheck_msgs.m:
compiler/unused_args.m:
compiler/unused_imports.m:
compiler/warn_unread_modules.m:
compiler/write_module_interface_files.m:
Conform to the changes above, mostly by either
- adding an option to all warning and informational messages,
sometimes using existing warning options and sometimes new ones,
or
- turning already explicitly-conditional-on-an-option messages
into implicitly-conditional-on-that-option messages.
---------------------
tests/invalid/one_member.m:
Conform to the change in det_infer_goal.m.
tests/invalid/require_tailrec_1.err_exp:
tests/invalid/require_tailrec_2.err_exp:
Actually obey the options for these modules in Mercury.options.
tests/invalid_purity/purity.err_exp:
tests/warnings/purity_warnings.err_exp:
Conform to the change in purity.m.
tests/warnings/moved_trace_goal.err_exp:
Conform to the change in mark_trace_goals.m.
tests/warnings/help_text.err_exp:
Expect the documentation of all the new options.
This implements some improvements to its idea from 2022 mar 19 on m-rev.
compiler/check_typeclass.m:
Consider an instance justifiably kept private if a constraint
on the instance refers to a private type class or type constructor.
Extend the test for what is considered "private" to also include
classes and type constructs that are defined in private submodules
of the current module.
Extend the text of the warning to explain the reasoning behind it.
compiler/options.m:
Extend the documentation of the option to explain the reasoning
behind it.
tests/invalid/impure_method_impl.err_exp:
tests/invalid/inconsistent_instances.err_exp:
tests/invalid/method_impl.err_exp:
tests/invalid/mpj_3.err_exp:
tests/invalid/mpj_4.err_exp:
tests/invalid/range_restrict.err_exp:
tests/warnings/unused_interface_import.err_exp:
Expect the new text for the warning.
tests/warnings/help_text.err_exp:
Expect the new help text.
This implements an idea from 2022 mar 8 on m-rev.
compiler/options.m:
Add this option.
compiler/check_typeclass.m:
Generate a warning that is conditional on this option if an instance
is local to the module even if both
- the class the instance is for, and
- all the type_ctors that occur in the instance's arg type vector
are visible outside the module.
Add an XXX about the status we record for instances.
NEWS.md:
Announce the new option.
tests/invalid/Mercury.options:
tests/warnings/Mercury.options:
Explicitly enable the new warning for some of the affected tests, and
explicitly disable it for others.
tests/invalid/impure_method_impl.err_exp:
tests/invalid/inconsistent_instances.err_exp:
tests/invalid/method_impl.err_exp:
tests/invalid/mpj_3.err_exp:
tests/invalid/mpj_4.err_exp:
tests/invalid/range_restrict.err_exp:
tests/warnings/help_text.err_exp:
tests/warnings/unused_interface_import.err_exp:
For the tests for which the new warning is enabled, expect that warning.
invalid/coerce_typecheck_eqv.m requires its helper module
coerce_typecheck_eqv_helper_1.m to abstractly export a type that is a
polymorphic equivalence type with a monomorphic definition.
That is not actually supported by the Mercury compiler yet,
but it only reports an error if we try to generate target code for
coerce_typecheck_eqv_helper_1.m (which we don't),
or while generating an intermodule optimisation interface file.
tests/invalid/Mercury.options:
Disable intermodule optimisation for the test case so as not to
generate the intermodule optimisation interface file.
compiler/make_hlds_passes.m:
Both fix and document the phasing problem.
compiler/add_pred.m:
Document the field here as well.
compiler/check_field_access_functions.m:
Delete the reference to this phasing problem.
tests/invalid/mode_without_pred.{m,err_exp}:
A test case for this issue, which compilers from before this fix
would have failed.
tests/invalid/Mmakefile:
Enable the new test.
Fix some aborts that could happen while type- or modechecking type
conversion expressions.
compiler/typecheck_coerce.m:
When building the set of invariant type parameters, handle a
constructor argument that has a type which is an (unexpanded)
equivalence type.
This fixes GitHub issue #137.
compiler/modecheck_coerce.m:
In modecheck_coerce_from_ground_make_inst_for_subtype,
handle a non-du or tuple type instead of aborting.
In get_ctor_arg_types_do_subst, handle a tuple type
instead of failing (leading to an abort).
tests/invalid/Mmakefile:
tests/invalid/coerce_typecheck_eqv.err_exp:
tests/invalid/coerce_typecheck_eqv.m:
tests/invalid/coerce_typecheck_eqv_helper_1.m:
Add test case.
tests/valid/Mmakefile:
tests/valid/coerce_modecheck_eqv.err_exp:
tests/valid/coerce_modecheck_eqv.m:
tests/valid/coerce_modecheck_eqv_helper_1.m:
Add test case.
tests/valid/gh137.m:
tests/valid/gh137_helper_1.m:
Delete original test case for GitHub issue #137,
as it is subsumed by tests/invalid/coerce_typecheck_eqv.m
NEWS.md:
Add news item for this, and previous changes.
compiler/mode_errors.m:
When a call matches none of the modes of the callee, we have long
generated message about all the arguments whose initial inst
is not right for *some* of the callee's modes. However, if there
is at least one argument whose initial inst is not right for *any* of
the callee's modes, then such arguments *definitely* represent bugs
that the programmer must fix, while any *other* arguments only *may*
represent bugs. but are actually quite likely to be completely ok
(since they *do* match one or more modes).
If there are any arguments that do not match any more, then report
only those arguments. If there are no such arguments, then keep the
report as is.
Simplify the approach handling all those arguments in two ways:
- use a two-arg structure instead of a map with two possible keys, and
- do not require the generation of piece lists for compiler-generated
arguments just so they can be dropped later.
tests/invalid/any_passed_as_ground.err_exp:
Do not expect the message component deleted by the change above.
compiler/options.m:
doc/user_guide.texi:
NEWS.md:
Add and announce the option.
compiler/style_checks.m:
Parse and check the new options.
Change how we implement the warn-non-contiguous-{clauses,foreign-procs}
options. Instead of immediately generating a diagnostic for every
predicate whose clauses are found to be non-contiguous, simply record
the fact of that non-contiguity. Once we have done this for all local
predicates, merge the clause item number ranges of any sets of predicates
whose clauses the new option allows to be intermingled, and treat the
result as if it came from a single predicate.
compiler/hlds_clauses.m:
Add a type for use by style_checks.m, and modify a predicate to use it.
compiler/mercury_compile_front_end.m:
Conform to the changes in style_checks.m.
tests/invalid/bad_allow_non_contiguity_for.{m,err_exp}:
Add this test case to check the diagnostics we generate
for each kind of error that may happen in the use of the new option.
tests/invalid/Mmakefile:
tests/invalid/Mercury.options:
Enable the new test case, and specify the bad options that
we want to test.
tests/warnings/allow_non_contiguity_for.{m,err_exp}:
Add this test case to check the normal operation of the new option.
tests/warnings/Mercury.options:
tests/warnings/Mmakefile:
Enable the new test case, and specify the good options that
we want to test.
tests/warnings/warn_non_contiguous.err_exp:
tests/warnings/warn_non_contiguous_foreign.err_exp:
Update the expected wording.
compiler/style_checks.m:
Move the code for generating those warnings here from typecheck_msgs.m.
Integrate the moved code into the structure of this module. Make that
structure clearer by
- explicitly documenting each kind of warning that this module
is responsible for generating (its tasks, of which there are
now three),
- putting the code of each task into a separate section of the module,
and
- giving predicates, function symbols and variables names that reflect
that same categorization.
compiler/typecheck_msgs.m:
Delete the code moved to style_checks.m.
compiler/typecheck.m:
Do not invoke the code that generates warnings for non-contigous clauses.
compiler/mercury_compile_front_end.m:
Document why we invoke style checks when we do.
compiler/hlds_clauses.m:
Document the fact that a slot in the clauses_info structure
is not currently useful,
tests/invalid/types.err_exp:
Do not expect a warning that is not helpful in the presence of the
messages for semantic errors that this test case is testing for.
compiler/pre_typecheck.m:
Split the "final statevar is unneeded" warning into two categories,
based on whether the initial version of that statevar is also unused,
or not. Generate different messages for the two situations.
For the "initial version of the statevar is used" category,
add a heuristic which says: do *not* generate this warning
if the mode of either the initial or the final statevar argument
involves uniqueness. This is to allow for code that uses e.g.
an <mdi, muo> pair of statevar arguments, and whose body passes
the initial version to a predicate as an mui argument. In such cases,
you need the final statevar to tell the caller that call did not
destroy the uniqueness of the passed state.
compiler/goal_util.m:
Add a new version of the goal_vars predicate for use by the new code
in pre_typecheck.m.
compiler/hlds_markers.m:
Add missing word in module comment.
compiler/inst_test.m:
Fix the comments describing two predicates.
compiler/mercury_compile_front_end.m:
Add a way to dump the HLDS version that the statevar warnings code
works with. (We dump the HLDS from *after* the statevar warnings code
is run, but since that code leaves the HLDS unchanged, the now-dumped
HLDS is also its input.)
compiler/state_var.m:
Add a utility predicate for use by the new code in pre_typecheck.m.
tests/invalid/try_io_else.err_exp:
Expect the new warning text for the "neither initial nor final version
is needed" case.
tests/warnings/unneeded_final_statevar.{m,err_exp}:
Add a test case for the operation of the new heuristic.
tests/warnings/Mmakefile:
Enable the new test case.
compiler/pre_typecheck.m:
Add a heuristic: do NOT generate a warning about unused final statevars
if all of a predicate's clauses are facts. In such cases, the warnings
are more noise than helpful.
compiler/add_clause.m:
Record for each clause whether it is a fact.
compiler/hlds_clauses.m:
Add a slot for this new fact_or_not flag.
compiler/add_foreign_proc.m:
compiler/add_pragma_type_spec.m:
compiler/add_pred.m:
compiler/hlds_out_pred.m:
compiler/instance_method_clauses.m:
compiler/intermod.m:
compiler/typecheck.m:
compiler/typecheck_clauses.m:
compiler/unify_proc.m:
compiler/var_origins.m:
Conform to the changes above.
compiler/options.m:
Turn the options on by default. Their documentation already assumes this.
NEWS.md:
Announce the new options warning about unneeded state variables.
tests/invalid/Mercury.options:
tests/invalid_purity/Mercury.options:
tests/invalid_nodepend/Mercury.options:
Turn the new warn options off for test cases that
- would otherwise get them, but
- for which this is irrelevant to what they want to test for.
tests/invalid/state_vars_test_5.err_exp:
tests/invalid/try_io_else.err_exp:
tests/warnings/unify_x_f_x.err_exp:
For these other cases, expect the new warnings.
compiler/add_heap_ops.m:
compiler/check_import_accessibility.m:
compiler/comp_unit_interface.m:
compiler/convert_import_use.m:
compiler/deforest.m:
compiler/dep_par_conj.m:
compiler/distance_granularity.m:
compiler/equiv_type.m:
compiler/generate_dep_d_files.m:
compiler/generate_mmakefile_fragments.m:
compiler/get_dependencies.m:
compiler/grab_modules.m:
compiler/higher_order.specialize_unify_compare.m:
compiler/jumpopt.m:
compiler/layout_out.m:
compiler/lco.m:
compiler/live_vars.m:
compiler/liveness.m:
compiler/llds_out_file.m:
compiler/make.build.m:
compiler/make.get_module_dep_info.m:
compiler/make.library_install.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.track_flags.m:
compiler/make_hlds_passes.m:
compiler/make_module_file_names.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_middle_passes.m:
compiler/ml_call_gen.m:
compiler/ml_closure_gen.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_disj_gen.m:
compiler/ml_elim_nested.m:
compiler/ml_foreign_proc_gen.m:
compiler/ml_lookup_switch.m:
compiler/ml_switch_gen.m:
compiler/ml_unify_gen_deconstruct.m:
compiler/ml_unify_gen_test.m:
compiler/mlds_to_c_file.m:
compiler/mlds_to_target_util.m:
compiler/module_cmds.m:
compiler/opt_deps_spec.m:
compiler/optimize.m:
compiler/parse_dcg_goal.m:
compiler/parse_goal.m:
compiler/parse_item.m:
compiler/parse_module.m:
compiler/parse_string_format.m:
compiler/proc_gen.m:
compiler/prop_mode_constraints.m:
compiler/rbmm.points_to_analysis.m:
compiler/rbmm.region_analysis.m:
compiler/rbmm.region_transformation.m:
compiler/simplify_goal_disj.m:
compiler/ssdebug.m:
compiler/stack_opt.m:
compiler/string_switch.m:
compiler/switch_gen.m:
compiler/term_constr_build.m:
compiler/trace_gen.m:
compiler/tupling.m:
compiler/untupling.m:
compiler/write_deps_file.m:
deep_profiler/autopar_calc_overlap.m:
deep_profiler/autopar_find_best_par.m:
deep_profiler/html_format.m:
deep_profiler/startup.m:
profiler/mercury_profile.m:
profiler/propagate.m:
Act on the new warnings. In a few cases, conform to the changes
resulting from acting on the warnings in other modules.
browser/Mercury.options:
compiler/Mercury.options:
library/Mercury.options:
mdbcomp/Mercury.options:
ssdb/Mercury.options:
Specify options for disabling the new warnings for modules
where we (probably) won't want them.
configure.ac:
Require the installed compiler to understand the options that
we now reference in the Mercury.options files above.
tests/debugger/tailrec1.exp:
Expect variable names for the middle versions of state vars
using the new naming scheme.
tests/invalid/Mercury.options:
Fix references to obsolete test names.
tests/warnings/Mercury.options:
Avoid a test failure with intermodule optimization.
The new --warn-unneeded-initial-statevar option asks the compiler
to warn about code such as
pred_a(!.X, ...) :-
... code that uses !.X, but does not update it ...
In this case, the preferred fix is to just replace all occurrences
of !.X with X.
The new --warn-unneeded-final-statevar option asks the compiler
to warn about code such as
pred_a(!X, ...) :-
... code that maybe uses !.X, but does not update it ...
In this case, the preferred fix also involves replacing all occurrences
of !.X with X, but it also involves either deleting the argument
containing !:X (the best option), or, if there is some reason why
the predicate's signature must stay unchanged, to replace !:X with X as well.
And if the clause body does not actually refer to either !.X or !:X, then
*both* arguments represented by !X should be deleted.
The first option is a style warning; the second option, due to the
signature change it may call for, is a non-style warning.
Both options have a version whose name adds a "-lambda" suffix, and which
does the same warnings for the heads of lambda expressions, not clauses.
Note that several of the modules below, including some that help to implement
the warnings, also contain code changes that result from *acting* on
the new warnings, e.g. by deleting unneeded statevar arguments.
Other, similar changes will also come after this diff is committed.
compiler/options.m:
doc/user_guide.texi:
Document the new options.
compiler/state_var.m:
Gather the information needed to decide what code merits the new warnings.
Do so in three stages:
- when processing the head of a clause or of a lambda expression,
- when processing the body goal of that clause or lambda expression,
- when finishing up the processing of the clause or lambda expression.
Add a predicate to generate the warnings for lambda expressions.
Do not generate the warnings for clauses. This is because whether or not
we want to warn about state vars in some clauses depends on the properties
of *other* clauses of the same predicate, and state_var.m has access
to only one clause at a time. Instead,
- return the info needed by the warning-generating code in pre_typecheck.m
(one of the first passes we execute after adding all clauses
to the HLDS), and
- we export some functionality for use by that code.
Switch to a convention for naming the program variables corresponding
to the middle (non-initial, non-final) versions of state variables
whose output is affected by changes in the code of the clause body goal
only if they involve that specific state variable.
Give some predicates more descriptive names.
compiler/make_hlds.m:
Make state_var.m and its new functionality visible from outside
the make_hlds package.
compiler/add_clause.m:
Record the information gathered by state_var.m in each clause.
compiler/hlds_clauses.m:
Add a slot to each clause for this information.
Give some predicates more descriptive names.
compiler/headvar_names.m:
Use the contents of the new slots to detect whether any clauses
have unused state vars, and if so, return the chosen consensus names
of the head vars to the code of pre_typecheck.m, which uses this info
as part of the implementation of the new warnings.
compiler/pre_typecheck.m:
Implement the new warnings.
compiler/mercury_compile_front_end.m:
Record the warnings that pre_typecheck.m can now return.
compiler/error_spec.m:
compiler/write_error_spec.m:
Add unsigned versions of the format pieces involving ints, for use
by the new code in pre_typecheck.m, and implement them.
compiler/hlds_out_util.m:
compiler/maybe_util.m:
Move two related types from hlds_out_util.m to maybe_util.m,
in order to allow pre_typecheck.m to use one of them.
compiler/hlds_args.m:
Add a new utility function for use by the new code above.
compiler/foreign.m:
Act on the new warnings by deleting the long-unused predicates
being warned about.
compiler/post_typecheck.m:
Speed up this traversal. (I originally thought to implement
the new warnings in this pass.)
compiler/add_foreign_proc.m:
compiler/add_pragma.m:
compiler/add_pragma_tabling.m:
compiler/add_pragma_type_spec.m:
compiler/add_pred.m:
compiler/add_type.m:
compiler/build_mode_constraints.m:
compiler/call_gen.m:
compiler/check_typeclass.m:
compiler/clause_to_proc.m:
compiler/code_loc_dep.m:
compiler/delay_info.m:
compiler/delay_partial_inst.m:
compiler/dense_switch.m:
compiler/det_check_goal.m:
compiler/det_infer_goal.m:
compiler/disj_gen.m:
compiler/du_type_layout.m:
compiler/format_call.m:
compiler/goal_expr_to_goal.m:
compiler/hlds_dependency_graph.m:
compiler/hlds_out_pred.m:
compiler/hlds_pred.m:
compiler/hlds_rtti.m:
compiler/inst_merge.m:
compiler/instance_method_clauses.m:
compiler/intermod.m:
compiler/interval.m:
compiler/ite_gen.m:
compiler/lookup_switch.m:
compiler/make_hlds_passes.m:
compiler/mark_tail_calls.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mode_errors.m:
compiler/parse_string_format.m:
compiler/passes_aux.m:
compiler/polymorphism.m:
compiler/polymorphism_info.m:
compiler/polymorphism_type_info.m:
compiler/pragma_c_gen.m:
compiler/prop_mode_constraints.m:
compiler/purity.m:
compiler/quantification.m:
compiler/simplify_goal_call.m:
compiler/simplify_goal_conj.m:
compiler/string_switch.m:
compiler/superhomogeneous.m:
compiler/switch_gen.m:
compiler/tag_switch.m:
compiler/type_constraints.m:
compiler/typecheck.m:
compiler/typecheck_clauses.m:
compiler/typecheck_coerce.m:
compiler/typecheck_error_unify.m:
compiler/unify_gen_deconstruct.m:
compiler/unify_proc.m:
compiler/var_origins.m:
Conform to the changes above, and/or act on the new warnings.
browser/diff.m:
library/bit_buffer.m:
library/getopt.m:
library/getopt_io.m:
library/io.error_util.m:
library/io.file.m:
library/mercury_term_lexer.m:
library/parsing_utils.m:
library/pretty_printer.m:
library/robdd.m:
library/rtti_implementation.m:
library/string.builder.m:
library/string.parse_runtime.m:
mdbcomp/feedback.m:
Act on the new warnings.
tests/hard_coded/sv_nested_closures.m:
Change this test's code to avoid the new warnings, since
(if --halt-at-warn is ever enabled) the warnings would interfere
with its job .
tests/invalid/bug197.err_exp:
tests/invalid/bug487.err_exp:
tests/invalid/nullary_ho_func_error.err_exp:
tests/invalid/try_detism.err_exp:
tests/warnings/singleton_test_state_var.err_exp:
Expect variable names for the middle versions of state vars
using the new naming scheme.
When warning about unresolved polymorphism involving an anonymous variable,
add to the diagnostic a description of the origin of the variable.
(Or origins, it if has more than one in different control branches.)
compiler/post_typecheck.m:
Change the wording we use to warn about unresolved polymorphism.
The old wording said that such warnings are *always* caused by calls
to polymorphic predicates, but this is not true, so say only that
it is *usually* caused by such calls.
If the warning is about the type of an anonymous variable,
then use the new module below to locate its first occurence in the code.
Without that info, the only way to locate the problem is reading
HLDS dumps, which is not something we can expect non-developers to do.
compiler/var_origins.m:
A new module to find and report variable's origins.
compiler/hlds.m:
compiler/post_typecheck.m:
Include and document the new variable.
tests/invalid/bug184.err_exp:
tests/invalid/freefree.err_exp:
tests/invalid/typeclass_test_8.err_exp:
tests/invalid/unsatisfiable_constraint.err_exp:
Expect the new wording of the warning, and (in some cases)
the extra info we now print.
tests/warnings/unresolved_polymorphism_anon.{m,exp}:
A test case specically for the new functionality.
tests/warnings/Mmakefile:
Enable the new test case.
These caused the tests in the mmc_make directory to be executed even
when they shouldn't have been, because the bootcheck did not specify
the --use-subdirs option. The root cause was probably the existence
of unintended Mercury directories, since this would cause mmake
to set MMAKE_USE_SUBDIRS to yes even without --use-subdirs.
tests/invalid/Mmakefile:
Clean up the Mercury directory created by a test case here.
tests/mmc_make/Mmakefile:
Clean up the Mercury directory created by all the test cases here.
Make a rule more robust.
Add a note about a currently unenabled test case.
tests/mmc_make/Mmakefile:
tests/valid_make_int/Mmakefile:
Test for --use-subdirs being enabled via the new variable
set by tools/bootcheck.
tools/bootcheck:
Record the value of --use subdirs in a variable, TESTS_USE_SUBDIRS,
that mmake does not know about and therefore will not touch.
Fix three unrelated issues that came up in bootchecks for testing
the above diff. They all involve the same small piece of code
whose job is to clean up .data and .procrep files left by bootchecks
in deep profiling grades.
- One issue was the lack of an update for the somewhat-recent change
in the naming of deep profiling data files;
- another was the lack of required parentheses on the find command line;
- and the third was the lack of protection for version-controlled files
that we do NOT want to delete.