compiler/simplify_proc.m:
If a first attempt to analyse and optimize format calls fails
due to insufficient information about format strings and/or values,
then try the whole process again after pushing copies of the format calls,
and the conjuncts that precede them, into the last preceding branched
control structure (disjunction, switch, or if-then-else). This will
fix the problem if each branch does construct known format strings
and/or values, and is harmless if this is not the case.
tests/valid/format_after_switch.m:
A test case for the new capability.
tests/valid/Mmakefile:
tests/valid/Mercury.options:
Enable the new test case.
compiler/error_spec.m:
Delete conditional_spec from the error_spec type, which had
exactly one use left in the compiler. Replace it with a conditional form
of severity_error, which handles that use case.
Rename error_severity to spec_severity, since obviously not all severities
represent errors.
For the same reason, rename error_phase to spec_phase.
compiler/error_util.m:
Export a predicate for write_error_spec.m.
compiler/write_error_spec.m:
Use that export to delete what used to be duplicate code.
compiler/add_pragma.m:
compiler/check_typeclass.m:
compiler/compiler_util.m:
compiler/error_sort.m:
compiler/mark_tail_calls.m:
compiler/parse_error.m:
compiler/parse_item.m:
Conform to the changes above.
compiler/switch_detection.m:
The existing switch detection algorithm does a single forward
traversal of the procedure body, doing only very limited lookahead.
This prevents it from recognizing some switches. To fix this, add
a new prepass that provides unlimited lookahead.
Add one use of this lookahead information. Later diffs should add
more uses.
compiler/print_help.m:
Fix the code that served as motivation for this change.
It was a block of unifications that was intended to supply
the lookahead that the old algorithm needed but did not have,
but it actually lied: it said that the the following disjunction
covered cons_ids that it actually did not cover. The fact that
the compiler did not diagnose this lie until now was a bug.
(After this diff, the compiler now reports an error.)
deep_profiler/message.m:
Avoid the limitation of the new algorithm that was discussed today
on m-dev.
compiler/options.m:
Add a way to test for the presence of this new capability
in the installed compiler.
tests/warnings/help_text.err_exp:
Expect the new option name.
compiler/options.m:
Add this prefix to the user-visible names of all the options
that specify flags that the compiler will pass to shell commands
*after quoting*. The internal names already had this prefix.
NEWS.md:
Document the new names, and the eventual names of the old names.
tests/warnings/help_text.err_exp:
Expect the new names as well as the old.
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.
tests/Mmake.common:
As above. This should fix the failure of invalid/foreign_decl_line_number
with clang, because we no longer ignore the expected output for situation,
which is in the test case's .err_exp6 file.
tools/bootcheck:
With --no-bootcheck in the Java grade, do not pass any runtime
options. The Java version of the runtime only supports a very
small subset of the options.
compiler/state_var.m:
Move an import to the implementation section.
compiler/mode_constraints.m:
compiler/mode_ordering.m:
compiler/stm_expand.m:
Avoid warnings about final statevars being unused.
compiler/Mercury.options:
Stop switching off the warnings this diff avoids, not just for the
above three modules, but also for two others, one of which
(parse_module.m) apparently had the warnings a while ago,
while the second (prog_event.m) never got them in the first place.
compiler/prog_event.m:
Remove an ambiguity.
library/cord.m:
Delete the unit_node function symbol, since it is just a special case
of the list_node function symbol. Reducing the number of function symbols
that traversals have to choose between gains more performance than
using two-argument list_nodes to replace one-argument unit_nodes loses.
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_clauses.m:
compiler/typecheck_error_overload.m:
Move the code that checks for ambiguity to the module that reports it.
Give some predicates better names. Put input args before in,out arg pairs.
Define predicates in the order in which they are called.
compiler/typecheck.m:
Conform to the changes above.
typecheck_unify_var_functor.m used to have separate code paths
- to handle the functors of builtin types, and
- to handle the functors of all other types.
However, the second path invoked code in typecheck_cons_infos.m that
*also* handled builtin types.
compiler/typecheck_unify_var_functor.m:
Simplify this arrangement by deleting the code that chose between
the two paths, and handling functors of builtin types together with
all the other functors in (what used to be) the second path.
compiler/typecheck_cons_infos.m:
Return a distinct result for cons_ids of all builtin types
(including some that typecheck_unify_var_functor.m did not handle
via the first code path.)
Document the meanings of the possible results.
compiler/hlds_cons.m:
Change the ctor_field_table type to encode the invariant
that we don't map sym_names to the empty list of field definitions.
compiler/hlds_pred.m:
The predicates that test whether a sym_name/arity pair or pred_info
refer to a field access function must search the ctor_field_table
to answer the question. Make them return the info they get from that
search, to save their callers from having to do it again.
Give a predicate a more meaningful name.
compiler/typecheck_info.m:
Record extra info if we are typechecking in a field access function,
since it may be needed, and storing it costs next to nothing.
compiler/add_clause.m:
compiler/add_type.m:
compiler/check_field_access_functions.m:
compiler/field_access.m:
compiler/intermod_decide.m:
compiler/pre_typecheck.m:
compiler/recompilation.check.m:
compiler/recompilation.usage.m:
compiler/resolve_unify_functor.m:
compiler/typecheck_error_undef.m:
Conform to the changes above.