compiler/parse_item.m:
Add previously missing code for parsing promise_ex declarations
(promise_exclusive, promise_exhaustive, and promise_exclusive_exhaustive)
of the form ":- all [vars] promise_ex... goal."
Comment out the code for parsing another form of such declarations,
":- promise_ex... goal.", which also had missing code and thus
never worked.
Check whether the first argument of a "some" or "all" quantifier
is a list of variables in just one place.
compiler/status.m:
Fix a bug in code that already had an XXX. Without this fix,
the new test case would get a spurious error from check_promise.m.
compiler/check_promise.m:
Fix several instances of another bug uncovered by the fix in status.m.
The problem was that the code that checked promises in the interface
section to see whether they contained any inappropriate references
to predicates or data constructors defined in the implementation section
considered, due to the bug now fixed in status.m, predicates and data
constructors imported from other modules to be defined in the
implementation section of this module. In fact, it did not even consider
the question of whether the predicate or data constructor was defined
in the current module at all.
Fixing this requires making a choice: may promises in the interface
refer to predicates and data constructors defined in other modules,
or not? The language manual does not answer this question, or any
other, about promises, since (a) all its documentation of promise
declarations is commented out, and (b) even the commented-out prose
is silent on references to other modules in promises.
The fix chosen by this diff is to let a promise refer to other modules
only if it is in the implementation section. The reason for this is that
I would find it strange to have module A rely on a promise made by
module B about the properties of e.g. a predicate in module C.
While having the code of module B itself rely on a promise that
module B itself makes about module C is not ideal, at least if the
promise is wrong, the effect of the wrong promise will be local.
(In a review comment, Julien pointed out that having module B make promise
about a predicate in module C may make sense if module C was provided
by an external entity, which may make moving the promise itself
to module C problematic in practice.)
Make error messages clearer via additional punctuation.
compiler/intermod.m:
Make the result of writing out a promise look better.
compiler/parse_tree_out.m:
Make the code writing out promises add a parentheses, without which
we could not read the promise back in.
tests/valid/promise_ex.m:
Add a test case for whether we can parse a promise_ex declaration.
tests/valid/Mmakefile:
Enable the new test case.
tests/invalid/assert_in_interface.err_exp:
Expect the error message we now generate for cross-module promises
in interface sections.
tests/invalid/tricky_assert1.err_exp:
Expect additional punctuation in an error message.
We used to generate diagnostics of the form
The predicate symbol predicate `<'/2 is also overloaded here.
The second "predicate" is pure noise. It could never be "function",
even though the code generating that message was prepared for that.
compiler/typecheck.m:
When typechecking a *predicate* call, don't specify the predicate
being called using a data structure that can also refer to functions.
compiler/typecheck_info.m:
When representing an overloaded predicate name, as opposed to
an overloaded function name, don't include a pred_or_func indication
that should *always* be pf_predicate.
compiler/typecheck_errors.m:
When reporting an overloaded predicate name, or talking about a
predicate's argument vector, do not take a pred_or_func indication,
since it should *always* be pf_predicate.
tests/invalid/ambiguous_overloading_error.err_exp:
tests/warnings/ambiguous_overloading.exp:
Don't expect the redundant "predicate" in the overload error message.
tests/invalid/max_error_line_width.err_exp:
tests/invalid/max_error_line_width.m:
The deletion of the redundant "predicate" in overload error messages
made them all fit on one line, robbing this test of its task of testing
longer-than-80-column output lines. Change the test so that the overload
is not between int.< and float.<, but between the unchecked_left_shift
functions in int and uint, since the longer function name yields error
message lines in the length range this test case wants to test.
tests/invalid/ambiguous_overloading_error.m:
tests/invalid/arg_permutation.m:
tests/invalid/assert_in_interface.m:
tests/invalid/bad_detism_category.m:
Fix programming style.
tests/invalid/assert_in_interface.err_exp:
Update a line number.
tests/invalid/*.{m,err_exp}:
tests/misc_tests/*.m:
tests/mmc_make/*.m:
tests/par_conj/*.m:
tests/purity/*.m:
tests/stm/*.m:
tests/string_format/*.m:
tests/structure_reuse/*.m:
tests/submodules/*.m:
tests/tabling/*.m:
tests/term/*.m:
tests/trailing/*.m:
tests/typeclasses/*.m:
tests/valid/*.m:
tests/warnings/*.{m,exp}:
Make these tests use four-space indentation, and ensure that
each module is imported on its own line. (I intend to use the latter
to figure out which subdirectories' tests can be executed in parallel.)
These changes usually move code to different lines. For the tests
that check compiler error messages, expect the new line numbers.
browser/cterm.m:
browser/tree234_cc.m:
Import only one module per line.
tests/hard_coded/boyer.m:
Fix something I missed.
Estimated hours taken: 28
Branches: main
A big step towards cleaning up the way we handle errors. The main changes are
- the provision, in error_util.m, of a mechanism for completely specifying
everything to do with a single error in one data structure,
- the conversion of typecheck_errors.m from using io.write_string to
using this new capability,
- the conversion of mode_errors.m and det_report.m from using
write_error_pieces to using this new capability, and
- consistently using the quoting style `symname'/N instead of `symname/N'
in error_util and hlds_error_util (previously, error_util used the former
but hlds_error_util used the latter).
This diff sets up later diffs which will collect all error specifications
in a central place and print them all at once, in order.
compiler/error_util.m:
The new type error_spec, which completely specifies an error.
An error_spec may have multiple components with different contexts
and may have parts which are printed only under certain conditions,
e.g. a given option being set. Each error_spec has a severity
and also records which phase found the error.
The new predicate write_error_spec takes care of updates of the exit
status for errors and (if --halt-at-warn is set) for warnings. It also
takes care of setting the flag that calls for the reminder about -E
at the end.
This diff also makes it simpler to use the ability to print arbitrary
output. It adds the ability to include integers in messages directly,
and the ability to create blank lines. It renames some function symbols
to avoid ambiguities.
Move a predicate that only used by typecheck_errors.m to that file.
compiler/hlds_error_util.m:
Switch to the `symname'/N quoting style for describing predicates and
procedures.
compiler/prog_util.m:
Switch to the `symname'/N quoting style for describing
sym_name_and_arity.
compiler/hlds_module.m:
Provide a predicate to increment the number of errors not by one,
but by the number of errors printed by write_error_spec.
Fix some documentation rot.
compiler/typecheck_errors.m:
Use write_error_spec instead of io.write_strings to print error
messages. In several cases, improve the formatting of the messages
printed.
Mark a number of places where we don't (yet) update the number of
errors in the module_info correctly.
Rename the checkpoint predicate to avoid potential ambiguity with
similar predicates in e.g. mode_info.
compiler/typecheck_info.m:
Group the code for writing stuff out together in one bunch. For each
such predicate, create another that returns a list of format components
instead of doing I/O directly.
compiler/typecheck.m:
Move the code for writing inference messages here from
typecheck_errors.m, since these messages aren't errors.
compiler/mode_errors.m:
compiler/det_report.m:
Use write_error_spec instead of write_error_pieces. In the case of
mode_errors.m, this means we now get correct the set of circumstances
in which we set the flag that calls for the reminder about -E.
compiler/add_pragma.m:
compiler/add_type.m:
Convert some code that used to use write_error_pieces to print error
messages to use write_error_spec instead.
compiler/assertion.m:
compiler/hlds_pred.m:
compiler/post_typecheck.m:
Assertion.m used to contain some code to check for assertions in the
interface that mention predicates that are not exported. Move most
of this code to post_typecheck.m (which is where this code used to be
called from). One small part, which is a test for a particular property
of import_statuses, is moved to hlds_pred.m to be with all the other
similar tests of import_statuses.
compiler/prog_util.m:
Change unqualify_name from a predicate to a function.
compiler/pred_table.m:
compiler/hlds_out.m:
Avoid some ambiguities by adding a suffix to the names of some
predicates.
compiler/*.m:
Conform to the changes above.
library/list.m:
Add a function that was previously present (with different names)
in two compiler modules.
tests/hard_coded/allow_stubs.exp:
Update the format of the expected exception.
tests/invalid/errors2.err_exp2:
Remove this file. As far as I can tell, it was never the correct
expected output on the main branch. (It originated on the alias branch
way back in the mists of time.)
tests/invalid/*.err_exp:
tests/invalid/purity/*.err_exp:
tests/warnings/*.exp:
Update the format of the expected error messages.
tests/recompilation/*.err_exp.2:
Update the format of the expected messages about what was modified.
Estimated hours taken: 10
Branches: main, release
Do not allow discriminated unions with a single zero-arity constructor to have
user-defined equality or comparison. Defining such types causes an assertion
failure in the compiler because the types are considered to be dummy types and
the runtime currently doesn't support (and probably won't ever) d.u. dummy
types with user-defined equality or comparison.
Fix another bug where the compiler was not printing out the `recompile with
-E' prompt at the appropriate time. The bug was caused by the fact that there
were several copies of the globals structure and the one that was being
checked at the time the prompt was being printed out was not the one that had
been updated during the rest of compilation.
compiler/add_types.m:
Emit an error message if an attempt is made to define a d.u. dummy
type with user-defined equality or comparison.
compiler/globals.m:
Remove the extra_error_info field from the globals structure and turn
it into a mutable. Export access predicates for this mutable. The
reason for doing this is that the compiler was sometimes looking at
the wrong copy of the globals structure when checking the value of
this flag - this meant that sometimes the recompile with `-E' prompt
was not being displayed. Turning this flag into a mutable avoids the
problem because now there is only one copy.
compiler/make_hlds.m:
s/__/./ in a few spots.
doc/reference_manual.texi:
Mention the new restrictions on discriminated union types with
user-defined equality or comparison.
tests/invalid/exported_unify2.m:
tests/invalid/exported_unify3.m:
Change some types with user-defined equality or comparison so that
they are no longer dummy types. These test cases have not been
triggering the assertion failure in the compiler because they are only
error checked and the assertion that is failing occurs further along
in the compilation process.
tests/invalid/user_eq_dummy.{m,err_exp}:
Test the new error message for dummy types with user-defined equality
or comparison.
tests/invalid/extra_info_prompt.{m,err_exp}:
Test that the recompile with `-E' prompt is being displayed when it
should.
tests/invalid/Mercury.options:
tests/invalid/Mmakefile:
Include the new test cases.
Where there is a verbose version of the error message compile with
`-E'.
tests/recompilation/add_type_re.err_exp.2:
tests/invalid/*.err_exp:
Update expected outputs to conform to the above.
Estimated hours taken: 1.5
Branches: main
Do not display the `For more information try recompiling with `-E'' prompt
unless we really mean it, i.e. there is actually more information available.
XXX This change is incomplete for the mode_errors module because that
module requires more substantial changes to make this work - I'll do
that as a separate diff.
compiler/globals.m
Add a new global (and access predicates) that keeps track of whether
we have any verbose error information that could be displayed if we
recompiled with `-E'.
compiler/mercury_compile.m
Check the new global flag before prompting the user to recompile with
`-E'.
compiler/mode_errors.m
Add an XXX comment about needing to respect the extra error info flag
properly.
compiler/accumulator.m
compiler/add_clause.m
compiler/add_pred.m
compiler/add_type.m
compiler/assertion.m
compiler/check_typeclass.m
compiler/det_report.m
compiler/magic_util.m
compiler/make_hlds_error.m
compiler/modes.m
compiler/module_qual.m
compiler/modules.m
compiler/post_typecheck.m
compiler/purity.m
compiler/stratify.m
compiler/typecheck_errors.m
Set the new global flag when we come across an error
for which we have a verbose error message.
tests/recompilation/*:
tests/invalid/*:
Update expected error files.
Estimated hours taken: 8
Branches: main
analysis/analysis.m:
browser/browse.m:
compiler/accumulator.m:
compiler/assertion.m:
compiler/atsort.m:
compiler/c_util.m:
compiler/check_typeclass.m:
compiler/clause_to_proc.m:
compiler/code_gen.m:
compiler/code_model.m:
compiler/const_prop.m:
compiler/constraint.m:
compiler/dead_proc_elim.m:
compiler/delay_construct.m:
compiler/dependency_graph.m:
compiler/det_analysis.m:
compiler/det_report.m:
compiler/export.m:
compiler/fact_table.m:
compiler/follow_code.m:
compiler/graph_colour.m:
compiler/hlds_module.m:
compiler/inlining.m:
compiler/llds.m:
compiler/make_hlds.m:
compiler/mercury_to_mercury.m:
compiler/ml_tailcall.m:
compiler/ml_unify_gen.m:
compiler/mmc_analysis.m:
compiler/mode_errors.m:
compiler/passes_aux.m:
compiler/post_typecheck.m:
compiler/size_prof.m:
compiler/switch_util.m:
compiler/table_gen.m:
compiler/term_errors.m:
compiler/transform_llds.m:
compiler/type_util.m:
compiler/unify_gen.m:
compiler/unneeded_code.m:
compiler/unused_args.m:
Bring these modules up to our current coding standards. Use predmode
declarations and state variable syntax where relevant. Reorder
arguments where this is needed for the use state variables. Make the
orders of predicate definitions correspond to the order of their
declarations. Replace some overly large lambda expressions with named
predicates. Convert some predicates to functions where this makes
their use more convenient. Use field access notation where convenient.
Fix any inconsistent indentation. Remove module prefixes on predicate
names where this is necessary to allow sane indentation.
In several places, use predicates from error_util.m to print error
messages. Apart from this, there are no changes in algorithms.
In some places, conform to the changes below.
compiler/error_util.m:
compiler/hlds_error_util.m:
Add new variants of existing predicates for use in some of the
changed modules above.
compiler/hlds_out.m:
Add some functions to convert values of some HLDS types as strings,
for use in preparing the arguments of the new calls to predicates in
error_util.m. Change the implementations of the predicates that print
values of those types to call those functions instead of allowing
code duplication.
compiler/llds.m:
Add some field names to allow use of field updates where relevant.
tests/invalid/assert_in_interface.err_exp:
tests/invalid/multisoln_func.err_exp:
tests/invalid/tricky_assert1.err_exp:
Update the expected outputs of these test cases to allow for them being
generated by error_util.m, and hence being better formatted than
before.
Estimated hours taken: 14
Branches: main
Change the compiler and tools so that `.' and not `:' is now used as the
module separator in all output.
Infix `.' now has associativity yfx and priority 10.
NEWS:
Report the change.
configure.in:
Amend the test for an up-to-date Mercury compiler to check whether
it recognises `.' as a module qualifier.
compiler/code_gen.m:
compiler/error_util.m:
compiler/hlds_out.m:
compiler/prog_out.m:
compiler/prog_util.m:
compiler/rl_exprn.m:
compiler/rl_gen.m:
compiler/source_file_map.m:
compiler/unused_args.m:
library/io.m:
library/rtti_implementation.m:
library/type_desc.m:
runtime/mercury_debug.c:
runtime/mercury_deconstruct.c:
runtime/mercury_stack_trace.c:
Change `:' to `.' as module separator for output.
compiler/mercury_to_mercury.m:
compiler/prog_io_typeclass.m:
As above.
Fixed a bug where `.' was not being recognised as a module separator.
doc/reference_manual.texi:
Report the change.
library/term_io.m:
Ensure that infix `.' is written without surrounding spaces.
tests/hard_coded/dot_separator.m:
tests/hard_coded/dot_separator.exp:
tests/hard_coded/Mmakefile:
Test case added.
Estimated hours taken: 1
Change from using `:- assertion' to `:- promise'.
invalid/assert_in_interface.err_exp:
invalid/assert_in_interface.m:
invalid/tricky_assert1.err_exp:
invalid/tricky_assert1.m:
valid/tricky_assert2.m:
Make the required changes.
Estimated hours taken: 1
Tests of assertions which are in the interface section of a module.
tests/invalid/Mmakefile:
tests/valid/Mmakefile:
Call the new tests.
tests/invalid/assert_in_interface.m:
tests/invalid/assert_in_interface.err_exp:
Test that an assertion in the interface detects that one of the
symbols in the assertion comes from a module imported in the
implementation.
tests/invalid/tricky_assert1.m:
tests/invalid/tricky_assert1.err_exp:
Test that `:- external' declarations are handled correctly.
tests/valid/tricky_assert2.m:
Test that `:- external' declarations are handled correctly.