doc/reference_manual.texi:
NEWS:
Document and announce the new pragma.
compiler/prog_data_pragma.m:
compiler/prog_item.m:
Provide a representation for the new pragma. The part that ends up
being referred to from the HLDS goes into prog_data_pragma.m,
the part that is not needed once the HLDS has been constructed
goes into prog_item.m.
compiler/hlds_pred.m:
Add a slot to pred_infos for info from the new pragma.
Fix a bug in the comment on marker_has_format_call.
compiler/add_pragma.m:
Add the information in these pragmas to the HLDS.
compiler/check_pragma_format_call.m:
A new module to check the validity of format_call pragmas.
These checks test whether the arguments named in such pragmas
have the expected types and modes, which means that
the check must be done after both type and mode checking.
compiler/check_hlds.m:
compiler/notes/compiler_design.html:
Add and document the new module.
compiler/hlds_module.m:
Add a field to the module_info that records the set of pred_ids
that have format_call pragmas.
compiler/mercury_compile_front_end.m:
Invoke the check_pragma_format_call pass *provided* that
the new field in the module_info says it has any pragmas to check.
compiler/parse_pragma.m:
Add code to parse the new pragma.
compiler/format_call.m:
Check calls to predicates and functions with the new pragma
the same way as we check calls to string.format, io.format,
and stream.string_writer.format.
This required separating the code that checked calls to such predicates
from the code that optimized calls to such predicates, since
- a predicate or function with a format_call pragma that specifies
more than one argument pair has to have its correctness checked
for each pair, and
- a predicate or function with a format_call pragma does not actually
do any formatting, so that formatting cannot be optimized.
Fix an old bug, where we included the function result in the function's
reported arity, which meant that an error message could mention a call
to a nonexistent function. As part of that fix, the error message
now specifies whether it is complaining about a call to a predicate
or a function.
Change the exported interface of this module a bit
in order to allow the factoring out of repeated code.
compiler/parse_string_format.m:
Separate the parsing of format strings from their optimization,
again because calls to predicates and functions with format_call
pragmas need to be checked but cannot be optimized.
compiler/polymorphism.m:
Record the effect on argument numbers of any type_info and/or
typeclass_info arguments added by this pass.
compiler/convert_parse_tree.m:
compiler/det_analysis.m:
compiler/direct_arg_in_out.m:
compiler/equiv_type.m:
compiler/get_dependencies.m:
compiler/hlds_out_pred.m:
compiler/item_util.m:
compiler/module_qual.qualify_items.m:
compiler/parse_tree_out_pragma.m:
compiler/prog_item_stats.m:
compiler/recompilation.version.m:
compiler/simplify_proc.m:
Conform to the changes above.
tests/invalid/bad_format_call.{m,err_exp}:
A new test case to see whether check_pragma_format_call.m detects
and reports invalid format_call pragmas as expected.
tests/warnings/format_call_warning.{m,exp}:
tests/warnings/format_call_warning_helper.m:
A new test case to see whether we generate the expected set of error
messages for incorrect calls to a predicate with a format_call pragma.
tests/invalid/Mmakefile:
tests/warnings/Mercury.options:
tests/warnings/Mmakefile:
Enable the new test cases.
tests/invalid/string_format_bad.err_exp:
tests/invalid/string_format_unknown.err_exp:
tests/warnings/disabled_warning.exp:
Expect the predicate vs function distinction to the printed in
error messages about bad calls to formatting predicates and functions.
doc/reference_manual.texi:
NEWS:
Allow a disable_warning scope to override the setting of the
--warn-unknown-format-calls option to "yes" inside its scope.
compiler/prog_data.m:
Provide a representation for the new kind of disable-able warning.
compiler/parse_goal.m:
Parse the new kind of disable-able warning.
compiler/prog_out.m:
Print out the new kind of disable-able warning.
compiler/format_call.m:
Add a parameter to the format checking code to control whether
we generate this warning. Using this parameter yields clearer code
that locally overriding the value of the option.
compiler/simplify_goal_scope.m:
Ignore the new kind of disable-able warning in code that has nothing
to do with it.
compiler/options.m:
doc/user_guide.texi:
Fix an old issue: include stream.string_writer.format in the description
of --warn-unknown-format-calls.
tests/warnings/disabled_warning.{m,exp}:
Add a test of the new functionality.
tests/warnings/Mmakefile:
tests/warnings/Mercury.options:
Enable the new test case.
The tests below are not actually invalid, they cause the compiler to emit only
warnings and properly belong in the warnings directory.
tests/invalid/empty_interface.{m,err_exp}:
tests/invalid/foreign_singleton.{m,err_exp}:
tests/invalid/obsolete_proc_pragma.{m,err_exp}:
Shift these tests into the warnings directory and use the
appropriate extension for expected outputs in that directory
tests/invalid/Mmakefile:
tests/invalid/Mercury.options:
tests/warnings/Mercury.options:
tests/warnings/Mmakefile:
Conform to the above changes.
compiler/add_clause.m:
Generate a warning for mode-specific clauses when the clause is for
a predicate that has only one mode, provided that the warning is enabled.
compiler/options.m:
Add an option to enable this warning.
doc/user_guide.texi:
Document this option.
library/exception.m:
library/int.m:
library/rtti_implementation.m:
library/string.m:
Delete modes from clause heads that would get this warning.
tests/valid/spurious_purity_warning.m:
Delete modes from clause heads that would get this warning.
Do not interleave predicate definitions.
tests/warnings/unneeded_mode_specific_clause.{m,exp}:
A test case for this warning.
tests/warnings/Mmakefile:
Enable the new test case.
tests/invalid/multimode_syntax.err_exp:
Expect the new warning.
compiler/mercury_compile_main.m:
I added that option a week or so ago, but at that time, it did nothing.
This diff implements the warning.
library/LIB_FLAGS.in:
Disable the warning for the modules in the library directory.
configure.ac:
Require the installed compiler to recognize the option, since without this,
library/LIBFLAGS won't work.
tests/warnings/profiling_builtin.{m,exp}:
tests/warnings/time.{m,exp}:
tests/warnings/time.subtime.m:
Two test cases for the warning. One, time, shadows the name of
a documented library module, the other, profiling_builtin,
shadows the name an undocumented library module.
The purpose of time.subtime is to test the message when the module name
*contains* a stdlib module name, but is not *identical* to it.
tests/warnings/Mmakefile:
Do *not* turn on the new test cases, but do document why we do not do so.
This means that we can do the exact same checks (and, if needed, generate
the exact same error messages) when generating interface files as when
generating target language code.
This should also allow us to simplify the process of adding type, inst
and mode definitions to the HLDS.
compiler/prog_item.m:
As above.
Delete unused function.
compiler/error_util.m:
Add mechanisms that allow us to distinguish (a) error specs that represent
a type, inst or mode name definition being invalid, from (b) other error
specs.
compiler/check_type_inst_mode_defns.m:
Improve the error messages we generate, in several ways.
First, for each message, specify a real severity. When the messages
could be seen only when generating interface files, making them all
warnings was fine and preserved old behavior, but since soon these
will be the only place for these checks, we need to call errors errors.
Second, specify, in the phase, which errors represent a invalid type,
inst or mode definition, and which don't.
Third, improve the wording of messages. In some places, do this by
being clearer about the distinction between declarations and definitions.
In others, do it by including more information in the message. In yet
others, do it by recovering some kinds of mistakes (mostly items being
in the wrong section) enough to avoid avalanche errors.
Fourth, fix a bug. If a type ctor has an exported *declaration*,
then it is ok for any foreign type definitions for that type_ctor
being in the implementation section, but if the type_ctor has an
exported Mercury *definition*, then any foreign_type definitions
must be in the interface section as well. The code that handled
both these situations did not enforce that.
Fifth, fix another bug: do not include foreign type definitions
in the source definitions of a type_ctor twice, once as a "du" (sic)
definition, and once as itself.
compiler/convert_parse_tree.m:
Check type, inst and mode definitions in raw_compilation_units
when creating parse_tree_module_srcs.
compiler/comp_unit_interface.m:
Make the code constructing interface files work from the checked maps
in parse_tree_module_srcs.
compiler/make_hlds_passes.m:
Set the flags that say we have found invalid type, inst or mode definitions
from the error specs constructed during the creation of the checked
type, inst and mode maps.
compiler/add_type.m:
Comment out an error message for a condition that will be detected and
reported by check_type_inst_mode_defns.m.
compiler/make_hlds_separate_items.m:
For now, turn checked maps of type, inst and mode definitions
back to item lists for addition to the HLDS. Adding whole checked
definitions to the HLDS will be done by a future change.
compiler/make_hlds_error.m:
Fix misleading indentation in an error message.
compiler/parse_tree_out.m:
Conform to the changes above.
Generate output whose indentation does not depend on tab settings.
compiler/check_raw_comp_unit.m:
compiler/equiv_type.m:
compiler/get_dependencies.m:
compiler/grab_modules.m:
compiler/module_qual.collect_mq_info.m:
compiler/module_qual.qualify_items.m:
Conform to the changes above.
compiler/parse_type_defn.m:
Fix misleading error message for ":- type <name> = <type>".
tests/debugger/foreign_type.{m,exp}:
Delete a redundant type declaration to avoid a warning, and update
the .exp file to expect the new line numbers.
tests/invalid/any_mode.err_exp:
tests/invalid/bug436.err_exp:
tests/invalid/bug476.err_exp:
tests/invalid/exported_foreign_enum.err_exp:
tests/invalid/fe_unmapped_nonverbose.err_exp:
tests/invalid/fe_unmapped_verbose.err_exp:
tests/invalid/foreign_enum_invalid.err_exp:
tests/invalid/foreign_solver_type.err_exp:
tests/invalid/foreign_type_visibility.err_exp:
tests/invalid/pragma_qual_error.err_exp:
tests/invalid/repeated_field_name.err_exp:
tests/invalid/subtype_foreign.err_exp:
tests/invalid/type_with_no_defn.err_exp:
tests/invalid/types2.err_exp:
tests/invalid/user_field_access_decl_conflict.err_exp:
tests/invalid_nodepend/bad_foreign_type.err_exp:
tests/invalid_nodepend/bigtest.err_exp:
tests/invalid_nodepend/invalid_typeclass.err_exp:
tests/invalid_nodepend/types.err_exp:
tests/invalid_nodepend/uu_type.err_exp:
tests/invalid_nodepend/where_abstract_enum.err_exp:
Expect the new error messages.
tests/invalid/abstract_solver_type.{m,err_exp}:
tests/warnings/abstract_solver_type.{m,exp}:
Move the abstract_solver_type test case from invalid to warnings, because
this diff changes its only error to be only a warning.
tests/invalid/Mmakefile
doc/reference_manual.texi:
Define the standard ordering of a subtype to be the same as that of
its base type.
Suggest that subtype constructors should be declared in the same
order as in the supertype.
compiler/add_type.m:
Warn if a subtype's constructors are declared in a different
relative order to the supertype.
compiler/unify_proc.m
Generate unify/compare procs for subtypes that cast to the base type
then call the unify/compare proc for the base type. This was
previously done only for the high-level data representation.
tests/hard_coded/Mmakefile:
tests/hard_coded/subtype_order.exp:
tests/hard_coded/subtype_order.m:
tests/warnings/Mmakefile:
tests/warnings/subtype_order.exp:
tests/warnings/subtype_order.m:
Add test cases.
My commit afe2887882 broke the ability
to run the test suite outside of a bootcheck by executing "mmake runtests"
in the tests directory. This diff fixes that.
tests/Mmake.common:
Don't define "TESTS_DIR = ..". While every single tests/*/Mmakefile
defined it as such, I overlooked the fact that tests/Mmakefile itself
defined it ".", referring to the same directory from a different starting
point. Document this easily-overlooked fact.
Rename the old runtests target, which after afe2887 runs the tests
in a single directory, as runtests_dir, to leave the target name
"runtests" itself free for tests/Mmakefile to use.
tests/Mmakefile:
Define "TESTS_DIR = .", and add a target "runtests" which invokes
"mmake runtests_dir" in each test directory.
tools/bootcheck:
Invoke "mmake runtests_dir" instead of "mmake runtests" in each
test directory.
Initialize a variable just before it is used.
tests/*/Mmakefile:
Add back the definition "TESTS_DIR = .."
A long time ago, test directories such as hard_coded had subdirectories
such as hard_coded/typeclasses. These have since been flattened out
(e.g. hard_coded/typeclasses is now just typeclasses), but there were
still remnants of the old approach. This diff deletes those remnants.
tests/*/Mmakefile:
Delete the TESTS_DIR and the SUBDIRS mmake variables; TESTS_DIR
was always set to "..", and SUBDIRS to the empty string.
Delete any references to the make variable NOT_WORKING, since
it is never used.
tests/Mmake.common:
Document that Mmakefiles in test directories don't have to set
TESTS_DIR and SUBDIRS anymore. Fix the formatting of the documentation
of the make variables they do still have to set.
Delete the targets and actions for handling subdirectories of
test directories, since there aren't any.
tests/Mmakefile:
Simplify some code.
This implements Mantis feature request #497.
compiler/parse_goal.m:
compiler/parse_dcg_goal.m:
When we find that a disable_warnings scope contains an unrecognized
warning name, generate a warning for it, and return this warning
*alongside*, not *instead of*, the disable_warnings scope goal.
This requires passing around not a maybe1(goal), as we have been doing
till now, but a maybe2(goal, list(warning_spec)), so this change
affects both (1) most of these two modules, and (2) most of the
modules below.
compiler/error_util.m:
Provide warning_spec as a synonym for error_spec, to be used in
situations like this where the "error_spec" is intended contain
something with severity_warning.
compiler/maybe_error.m:
Provide some new utility predicates now needed in parse_goal.m
and elsewhere.
compiler/prog_item.m:
Provide room in the representation of clauses for the warnings
generated by parsing the clause body goal.
compiler/add_class.m:
compiler/add_clause.m:
compiler/add_mutable_aux_preds.m:
compiler/add_pragma_tabling.m:
compiler/du_type_layout.m:
compiler/get_dependencies.m:
compiler/make_hlds_passes.m:
compiler/parse_item.m:
compiler/parse_tree_out_clause.m:
compiler/prog_item_stats.m:
compiler/superhomogeneous.m:
Conform to the changes above.
tests/valid/unknown_warning.m:
Add this test case that checks whether a source file with an unknown
warning name in a disable_warnings scope can have code generated for it.
tests/warnings/unknown_warning.{m,exp}:
Add the same source file to this directory as well, to check whether
we get the right set of warnings.
tests/valid/Mmakefile:
tests/valid/Mercury.options:
tests/warnings/Mmakefile:
Enable the two new test cases.
This fixes github issue #85.
A complication is that the compiler itself has code, in make.util.m,
in which a disjunct has no solutions in only one mode of a two mode
function, but in this case, the code works (though its programming style
is pretty bad), so to get this change to bootstrap, we also need
a way to disable the "this disjunct can't have solutions" warning
in a scope.
compiler/simplify_goal_disj.m:
When we generate a "this disjunct can't succeed" warning,
do not insist on all modes generating that warning.
We used to insist on that because in a multi-mode predicate,
such warnings can be inappropriate for other modes.
Instead, achieve the same objective of minimizing programmer
confusion by adding a codicil explicitly mentioninging
this possibility.
Make the generation of this warning conditional on a simplify task
that can be disabled by "disable_warnings" scope.
compiler/prog_data.m:
Add "no_solution_disjunct" as a warning kind that may be disabled.
compiler/parse_goal.m:
Parse the new kind of warning.
compiler/prog_out.m:
Output the new kind of warning.
Improve some adjacent though unrelated code.
compiler/make.util.m:
Add code disable this warning in the affected predicate.
Comment out this code until installed compilers know how
to parse it and understand it.
compiler/Mercury.options:
Don't turn warnings into errors for make.util.m until then.
compiler/simplify_goal_scope.m:
compiler/simplify_info.m:
compiler/simplify_tasks.m:
Provide the mechanism needed to make it possible to disable
warnings about no solution disjuncts.
doc/reference_manual.texi:
Document the new disable-able warning.
NEWS:
Document both the changed behavior of the old warning
and the new way to disable it.
tests/warnings/gh85.{m,exp}:
A regression test for the bug, based on the code in the
github issue. It also tests the way to disable the warning.
tests/warnings/Mmakefile:
Enable the new test case.
Until now, we have generated warnings about occurs check violations
in the HLDS. Since the HLDS is in superhomogeneous form, this means
we warn for X = f(X), but not for Xs = [X1, X2 | Xs]. The reason is
that the latter expands to Xs = [X1 | Xs1], Xs1 = [X2 | Xs],
and neither of those two unifications fails the occurs check by itself.
This diff switches to having that warning be generated during the creation
of the HLDS, by code that works on the original parse tree. That means
we can now generate warnings for code such as Xs = [X1, X2 | Xs].
NEWS:
Mention that fact.
compiler/superhomogeneous.m:
While expanding terms into superhomogeneous form, keep track
of which variables have been unified with a term *or an ancestor
of that term*. In the case above, we know that Xs1 is *part of* Xs,
so unifying it with [X2 | Xs] is an occurs check violation.
Conditionally generate a warning for such violations. This is only
a warning, because in the parse tree, function symbols can be not just
data constructors but also function applications, and we can't
say which is which. While X = f(X) is a real problem if f is
a data constructor, it may be perfectly ok code (a test for a
fixpoint) if f is a function.
compiler/modecheck_unify.m:
Disable the HLDS version of this warning, to avoid warning
about the problem twice. (This diff leaves the infrastructure
supporting the HLDS warning remains in place, in case we want
to enable it again.)
compiler/options.m:
Add the new warning option that the new warning is conditional on.
compiler/prog_data.m:
Add the new warning to the list of warnings that may be disabled
by a disable_warnings scope.
Change code to avoid the new warning.
compiler/goal_expr_to_goal.m:
Disable the new warning in goals inside a disable_warnings scope
that asks for it to be disabled.
compiler/parse_goal.m:
Parse the new warning in disable_warnings scopes.
compiler/prog_out.m:
Output the new warning in disable_warnings scopes.
compiler/simplify_goal_scope.m:
Ignore the new warning in disable_warnings scopes, since it is not
for use here.
library/term_to_xml.m:
Change code to avoid the new warning.
doc/reference_manual.texi:
doc/user_guide.texi:
Document the new warning option, and the means of suppressing the
warning using a disable_warnings scope.
tests/invalid/ambiguous_overloading_error.err_exp:
tests/invalid/max_error_line_width.err_exp:
tests/invalid/occurs.err_exp:
tests/warnings/unify_x_f_x.exp:
Update these expected outputs to expect the new warning,
and (in some cases) not to expect its HLDS version.
tests/warnings/occurs.{m,exp}:
A new test case to test not just the warning (the tests above do that
already) but also its suppression.
tests/warnings/Mmakefile:
Enable the new test case.
compiler/simplify_goal_call.m:
If the --warn-suspicious-recursion option is set, and if the warning
isn't disabled, generate warnings for two different kinds of suspicious
recursion. They are both related to, but separate from, the warning
we have long generated for infinite recursion, which occurs when
the input args of a recursive call are the same as the corresponding
args in the clause head.
Both kinds suspicious recursion look at the input args of a recursive call
that are NOT the same as the corresponding args in the clause head.
Both require these args to have non-unique modes. (If they have unique
modes, then the depth of the recursion may be controlled by state outside
the view of the Mercury compiler, which means that a warning would be
likely to be misleading.)
The first kind is when all these args use state variable notation.
Most of the time, we use state var notation to denote the data structures
updated by the recursive code; having variables using such notation
*controlling* the recursion is much less common, and much more likely
to be unintended. The motivation for the new option was this infinitely
looping code, which resulted from neglecting to s/[X | Xs]/Xs/ after
cutting-and-pasting the clause head to the recursive call.
p([X | Xs], !S) :-
...,
p([X | Xs], !S).
The other kind of suspicious recursive call we warn about involve
input arguments where the base names of the input arguments (the part
before any numeric suffixes) seem be switched between the clause head
and the recursive call, as here:
q(As0, Bs0, ...) :-
...,
q(Bs1, As, ...).
compiler/mercury_compile_main.m:
Disable style warnings when invoked with --make-optimization-interface
or its transitive variant. Without this, warnings about suspicious
recursion would get reported in such invocations.
Move a test from a callee to a caller to allow the callee to be
less indented.
compiler/options.m:
Export functionality to mercury_compile_main.m to make the above possible.
library/string.m:
Add a predicate to convert a string to *reverse* char list directly.
Note a discrepancy between the documentation and the implementation
of the old predicate the new one is based on (which converts a string
to a forward char list).
NEWS:
Note the new predicate in string.m.
compiler/cse_detection.m:
compiler/ctgc.selector.m:
compiler/dead_proc_elim.m:
compiler/deforest.m:
compiler/dep_par_conj.m:
compiler/det_analysis.m:
compiler/distance_granularity.m:
compiler/frameopt.m:
compiler/inst_util.m:
compiler/lp_rational.m:
compiler/matching.m:
compiler/modes.m:
compiler/old_type_constraints.m:
compiler/rbmm.points_to_analysis.m:
compiler/rbmm.region_arguments.m:
compiler/recompilation.usage.m:
compiler/stratify.m:
compiler/structure_reuse.direct.choose_reuse.m:
compiler/structure_reuse.indirect.m:
compiler/typeclasses.m:
compiler/use_local_vars.m:
deep_profiler/callgraph.m:
deep_profiler/canonical.m:
library/bit_buffer.read.m:
library/bit_buffer.write.m:
library/calendar.m:
library/diet.m:
library/lexer.m:
library/parser.m:
library/parsing_utils.m:
library/ranges.m:
library/set_ctree234.m:
library/set_tree234.m:
library/string.parse_util.m:
library/tree234.m:
library/varset.m:
mdbcomp/program_representation.m:
mdbcomp/rtti_access.m:
profiler/demangle.m:
Avoid warnings for suspicious recursion. In most cases, do this by
wrapping disable_warning scopes around the affected recursive calls;
in a few cases, do this by changing the code.
tests/warnings/suspicious_recursion.{m,exp}:
A test case for the new warnings.
tests/warnings/Mercury.options:
tests/warnings/Mmakefile:
Enable the new test case.
compiler/hlds_goal.m:
Add a goal feature that is intended to mark lambda goals
created to implement try goals.
compiler/try_expand.m:
Add this feature to the lambda goals created to implement try goals.
compiler/simplify_info.m:
Replace an old counter "number of lambdas we are inside" with a
slightly different counter "number of non-try lambdas we are inside".
Move the position of the counter in its structure to reveal
all the places that must be updated to account for this.
compiler/simplify_goal_unify.m:
Do NOT increment the changed counter while traversing lambda goals
that are part of the implementation of try goals.
compiler/simplify_goal_call.m:
We used to suppress the generation of warnings about infinite recursion
if we were inside any lambdas. This is because if the code of e.g.
"p(InArgs, OutArgsA)" constructs a higher order value that contains
the apparently-infinitely-recursive call "p(InARgs, OutArgsB)",
the code that calls the new closure may well be *outside* the call tree
of predicate p, and would thus no longer be recursive.
However, a closure constructed to implement a try goal *will* be called
inside the predicate that constructs it. So we now suppress the warning
only if the number of *non-try* lambdas we are inside is nonzero.
This is the motive behind the change in semantics in simplify_info.
This implements feature request Mantis #477.
compiler/simplify_proc.m:
compiler/saved_vars.m:
Conform to the changes above.
tests/warnings/bug477.{m,exp}:
A test case for the new functionality.
tests/warnings/Mmakefile:
Enable the new test.
If --warn-simple-code is enabled, then emit a warning for comparisons of
unsigned integer values against zero if that comparison is a tautology or
contradiction.
compiler/simplify_goal_call.m:
Implement the new warning.
tests/warnings/Mmakefile:
tests/warnings/unsigned_zero_cmp.{m,exp}:
Add a test of the new warning.
This causes the compiler to check the bodies of foreign_code pragmas in a
similar fashion to what --warn-suspicious-foreign-procs does for foreign_proc
pragmas. Currently, the only check that is performed is for the presence of
MR_ALLOC_ID in the pragma bodies.
compiler/options.m:
Add the new option.
compiler/add_pragma.m:
compiler/make_hlds_warn.m:
Implement the new check.
doc/user_guide.texi:
Document the new option.
tests/warnings/Mmakefile:
tests/warnings/Mercury.options:
tests/warnings/suspicious_foreign_code.{m,exp}:
Add a test of the new warning.
compiler/state_var.m:
Delete redundant copy unifications, whose mere presence can hide the fact
that the state variable instance being copied is a singleton.
compiler/add_clause.m:
Conform to the change in state_var.m.
compiler/hlds_goal.m:
Add a new goal feature for state_var.m to use to identify the copy goals
inserted by the state var transformation.
Add a mechanism to add more than feature to a goal at a time.
compiler/saved_vars.m:
Conform to the change to hlds_goal.m.
compiler/proc_gen.m:
Fix a singleton ocurrence of a state variable. This problem was hidden
until the bug fix in state_var.m described above.
tests/warnings/singleton_test_state_var.{m,exp}:
New regression test to test for the original bug.
tests/warnings/Mmakefile:
Enable the new test case.
One option, --warn-non-contiguous-decls, generates warnings if the
mode declarations of a predicate or function aren't in a contiguous block
immediately following the pred or func declaration. Since this is a rare
kind of "style error", this option is enabled by default.
Two options, --warn-inconsistent-pred-order-clauses and
--warn-inconsistent-pred-order-foreign-procs, warn about inconsistencies
between (a) the order in which predicates (and functions) are declared,
and (b) the order in which they are defined. The two options differ in
their scope. The latter applies to all predicates and functions defined
in the module, while the former applies only to those whose definitions
include Mercury clauses.
Since an exported predicate or function may need nonexported auxiliary
predicates and/or functions, imposing a single order the declarations and
definitions of *all* the predicates and functions in a module is not a good
idea. Instead, both options divide the predicates and functions defined
in a module two groups, the exported and the nonexported, and expect
a consistent order only within each group.
The result is output that looks like this:
time.m:021: Warning: the order of the declarations and definitions of the
time.m:021: exported predicates is inconsistent, as shown by this diff:
time.m:021:
time.m:021: --- declaration order
time.m:021: +++ definition order
time.m:021: @@ -1,7 +1,7 @@
time.m:021: predicate `clock'/3
time.m:021: -predicate `time'/3
time.m:021: predicate `times'/4
time.m:021: function `clk_tck'/0
time.m:021: +predicate `time'/3
time.m:021: function `difftime'/2
time.m:021: predicate `localtime'/4
time.m:021: function `localtime'/1
compiler/options.m:
doc/user_guide.texi:
Add the new options.
compiler/style_checks.m:
A new module that generates the new warnings if warranted.
compiler/check_hlds.m:
compiler/notes/compiler_design.html:
Include and document the new module.
compiler/mercury_compile_front_end.m:
Invoke the new module if any of the three new options is set.
compiler/hlds_pred.m:
Record the item number of every predicate, function, and mode declaration
in the module being compiled. We need this for information for the
new warnings.
compiler/hlds_module.m:
Record the context of the module declaration. We use this context
for warnings about inconsistent order, since there isn't a better one.
compiler/hlds_clauses.m:
Add a mechanism to retrieve the item numbers of a set of clauses
even if they are contiguous.
Document some old data types.
compiler/error_util.m:
Add a new phase for style checks.
compiler/accumulator.m:
compiler/add_class.m:
compiler/add_mutable_aux_preds.m:
compiler/add_pragma_tabling.m:
compiler/add_pred.m:
compiler/add_solver.m:
compiler/add_special_pred.m:
compiler/check_typeclass.m:
compiler/clause_to_proc.m:
compiler/from_ground_term_util.m:
compiler/lambda.m:
compiler/make_hlds.m:
compiler/make_hlds_passes.m:
compiler/mercury_compile.m:
compiler/par_loop_control.m:
compiler/polymorphism.m:
compiler/stm_expand.m:
compiler/table_gen.m:
compiler/unify_proc.m:
Conform the changes to the HLDS above.
compiler/typecheck_errors.m:
Fix style of error messages.
library/array2d.m:
library/assoc_list.m:
library/benchmarking.m:
library/bit_buffer.write.m:
library/bool.m:
library/builtin.m:
library/construct.m:
library/cord.m:
library/counter.m:
library/float.m:
library/injection.m:
library/lazy.m:
library/lexer.m:
library/ops.m:
library/private_builtin.m:
library/profiling_builtin.m:
library/prolog.m:
library/queue.m:
library/rational.m:
library/require.m:
library/stack.m:
library/std_util.m:
library/store.m:
library/thread.semaphore.m:
library/tree234.m:
library/univ.m:
library/version_store.m:
Move declarations or definitions around to avoid some of the warnings
that we can now generate. (There are many more left.)
Make some minor style improvements in the process.
tests/warnings/inconsistent_pred_order.{m,exp}:
tests/warnings/non_contiguous_decls.{m,exp}:
New test cases to test the new options. They are both copies of
tests/benchmarks/queens.m, with intentionally-screwed-up style.
tests/warnings/Mmakefile:
Enable the new test cases.
tests/warnings/Mercury.options:
Specify the options being tested for the new test cases.
tests/benchmarks/queens.m:
Bring the style of this module up to date (before copying it).
tests/invalid/mode_decl_in_wrong_section.err_exp:
Expect the warnings we now generate.
compiler/options.m:
doc/user_guide.texi:
NEWS:
Add the above option.
compiler/simplify_goal_call.m:
If the option is given, then generate severity_informational messages
for calls to I/O predicates such as io.write_string/3, which have twins
(in this case io.write_string/4) that take an extra initial argument
that explicit specifies the stream to do the I/O on.
Additionally, generate warnings for the predicates that update
the library's notion of the current input and outpuy streams,
since these are effectively the "enablers" for the calls that the
above paragraph describes.
Fix the conditions on some error specs.
Delete a duplicated comment.
compiler/simplify_tasks.m:
Add the new task to the list of tasks that simplification
may be asked to do.
compiler/simplify_info.m:
compiler/simplify_proc.m:
Fix an old minor bug: shut up *all* messages, whether their severity
is error, warning or informational, during the second pass of
simplification. (The need for the fix is described in the new comment
in simplify_proc.m.)
compiler/common.m:
compiler/simplify_goal.m:
compiler/simplify_goal_disj.m:
compiler/simplify_goal_ite.m:
Conform to the changes above.
tests/warnings/save.{m,exp}:
A new test case to test the new option.
tests/warnings/Mmakefile:
Enable the new test case.
Switch to a more consistent indentation style.
tests/warnings/Mercury.options:
Run the new test case with the new option.
tests/debugger/save.m:
The new test case, warnings/save.m, is a version of debugger/save.m
with up-to-date programming style. Update the original as well.
This fixes Mantis bug #412.
compiler/unused_imports.m:
Consider that an instance declaration makes a module "used" only if
it occurs in the module being compiled, not in an imported or ancestor
module. (Mantis bug 412 was caused by instance declarations in implicitly
imported modules.)
Fixing #412 also exposed another bug. When computing the set of modules
used by predicates, we considered (besides some non-type entities)
only the types of the predicate's arguments, not the types of non-argument
variables. In one case in the compiler (mmc_analysis.m), this lead to
some actually-used modules not being marked as such, which lead to
false unused-import warnings to be generated for them. Fix this by scanning
the types of all variables in all of a predicate's procedures, not just
the arguments.
Improve the infrastructure for debugging similar problems.
Note some possibilities for future improvement.
Change a predicate name to fit the naming scheme.
compiler/analysis.m:
Add an XXX about a possible improvement.
compiler/hlds_out_module.m:
Make the output we generate for instance methods more readable.
As part of this, fix an old bug in the printing of the instance table:
the first line of the first method of each concrete instance declaration
was accidentally commented out.
compiler/parse_tree_out.m:
Export a different utility predicate for hlds_out_module.m. Make its name
conform to the scheme used by related predicates.
browser/browse.m:
compiler/add_mutable_aux_preds.m:
compiler/add_pred.m:
compiler/add_special_pred.m:
compiler/check_for_missing_type_defns.m:
compiler/check_promise.m:
compiler/exception_analysis.m:
compiler/handle_options.m:
compiler/inst_match.m:
compiler/mercury_to_mercury.m:
compiler/ml_tailcall.m:
compiler/module_qual.m:
compiler/op_mode.m:
compiler/parse_inst_mode_defn.m:
compiler/parse_tree_out_clause.m:
compiler/parse_tree_out_info.m:
compiler/parse_tree_out_inst.m:
compiler/parse_tree_out_pragma.m:
compiler/parse_tree_out_pred_decl.m:
compiler/parse_tree_out_term.m:
compiler/parse_type_defn.m:
compiler/parse_type_name.m:
compiler/parse_util.m:
compiler/parse_vars.m:
compiler/prog_ctgc.m:
compiler/recompilation.usage.m:
compiler/resolve_unify_functor.m:
compiler/term_constr_main.m:
compiler/term_constr_main_types.m:
compiler/write_deps_file.m:
library/bt_array.m:
Delete unused imports.
compiler/module_qual.qual_errors.m:
Import a module that the parent module_qual.m doesn't import anymore.
tests/warnings/bug412.{m,exp}:
The test case for this bug.
tests/warnings/Mmakefile:
tests/warnings/Mercury.options:
Enable the new test case.
tests/invalid/import_in_parent.err_exp:
Update the expected output for this test case. The parent module
does not use the imported module (bool) at all, so this is what the
error message says after this diff, though its submodule does use bool.
compiler/det_report.m:
Generate an error message if a require_complete_switch [X] scope
is wrapped around a goal that is not a switch on X.
doc/reference_manual.texi:
Update the reference manual to document this change. Also fix an
old documentation problem: require_complete_switch scopes do NOT
require covering all the function symbols in the type of the
switch-on variable if the switched-on variable's inst says that
it cannot be bound to some of them.
compiler/hlds_goal.m:
Update the comment on the require_complete_switch scope
in the same way.
NEWS:
Announce the change.
tests/warnings/bug257.{m,exp}:
tests/invalid/bug257.{m,err_exp}:
tests/warnings/Mmakefile:
tests/invalid/Mmakefile:
For the bug257.m test case, which has a require_complete_switch [X] scope
around a goal that is not a switch on X, expect the error message
we now generate, not the old warning.
Since the compilation of bug257.m now fails, move it from warnings
to invalid.
tests/valid/Mmakefile:
Disable the bug257b.m test case, which also had a
require_complete_switch [X] scope around a goal that was not a switch on X.
tests/valid/bug257b.m:
Document that this test case is now disabled, and why.
Fix more failing test cases in the non-C grades.
compiler/mlds_to_java.m:
compiler/mlds_to_cs.m:
Always switch over unary and binary ops. The existing code predates
the addition of multi-arm switches to the language and was intended to
the code duplication that would result in the absence of that feature.
Since we now have multi-arm switches it is by far preferable to use
a switch in these places.
XXX for binary ops the above change replicates what the existing code
did; I think it should actually abort in some cases.
Fix spelling.
Delete trailing whitespace.
compiler/java_util.m:
Delete this module, it isn't used anymore.
compiler/ml_backend.m:
Delete the include of the java_util module.
compiler/c_util.m:
Update a comment.
tests/exceptions/Mmakefile:
Fix the failure of 'test_uncaught_exception' in the java grade by
filtering out the stack trace generated by the JVM.
tests/hard_coded/float_reg.exp4:
Alternative expected output for this due to the way floats are
printed.
tests/invalid_purity/purity.m:
tests/invalid_purity/purity.err_exp:
Add C# and Java foreign_procs and updated the expected output.
tests/warnings/Mmakefile:
Fix my previous change, which broke things in non-Erlang grades.
tests/warnings/Mmakefile:
Don't run the 'warn_return' test in the erlang grade;
it's test for something that isn't present in Erlang.
tests/warnings/singleton_test.exp4:
Update this expected ouptut -- the line nubmers in the
output have changed.
Often a procedure whose job is to verify an invariant or otherwise help with
debugging will be private to its defining module, and will be called only
from conditionally compiled trace goal scopes. If the trace goal's condition
is false, then the procedure will have no calls to it left by the time
we invoke dead_proc_elim. However, any warning that the compiler could print
to the effect that "the procedure is never called" would be incorrect
from the programmer's point of view, even though it would be correct
from the code generator's point of view.
compiler/simplify_goal_scope.m:
When deleting a trace goal scope because it is conditionally compiled
and its condition is false, compute the set of procedures called in
the deleted goal and record that set in a new slot of the simplify_info.
compiler/simplify_info.m:
Define a new slot for that purpose.
compiler/simplify_proc.m:
When we have finished processing a procedure, add the procedure ids
in the new slot of the simplify_info to a new slot of the procedure's
proc_info.
compiler/hlds_pred.m:
Define a new slot in the proc_info (actually, proc_sub_info)
for that purpose.
compiler/dead_proc_elim.m:
When we call dead proc elimination because we want to generate warnings,
treat the procedures named in these proc_info slots as if they were
actually called (since the source code actually contains calls to them).
When we call dead proc elimination because we want to delete unused
procedures from the HLDS, because we don't want to generate code for them,
we *don't* want to treat the appearance of a procedure id in this slot
as a call. We now therefore provide two separate predicates to call:
one (dead_proc_elim) that deletes procedures from the HLDS but returns
no warnings, and another (dead_proc_warn) that generates warnings
but leaves the HLDS unchanged. Besides the different in their
signatures, these two top level predicates use slightly different
criteria to decide whether a procedure is dead or not. (No current caller
wants both an updated HLDS *and* warnings. If new callers do, they will
have to call both predicates. This will find the set of called procedures
twice, but since their criteria of what they count as "called" will be
different, the set of "called" procedures they compute could differ.)
Parameterize the code that computes the set of needed entities
to allow it to be used for both purposes.
Split the old code that used to use the results of that analysis
to both delete procedures and to generate warnings for such deletions.
There is now one copy specialized for deleting unused procedures from the
HLDS, and one copy specialized for generating warnings. The two don't
actually have that much in common.
compiler/deep_profiling.m:
compiler/mercury_compile_middle_passes.m:
Update all the places that used to call dead proc elimination
to call instead one of its two replacement predicates.
compiler/hlds_out_pred.m:
Dump the new field in the proc_info if it is not empty.
tests/warnings/warn_dead_proc_trace.{m,exp}:
A new test case to test the new functionality.
tests/warnings/Mercury.options:
tests/warnings/Mmakefile:
Enable the new test case.
compiler/modules.m:
When a module imports itself, or one its warnings, we generate a warning.
Originally, the context of this warning was the first line of the module's
file, and later the context of the module's initial ':- module'
declaration, but the right context is the context of the relevant
`:- import_module' or `:- use_module' declaration. Find this context
and use it.
Print the explanation about why ancestor modules need not be explicitly
imported at most once.
tests/warnings/warn_self_import.{m,exp}:
A new test case to test the fix.
tests/warnings/Mmakefile:
tests/warnings/Mercury.options:
Enable the new test case.
tests/Mmake.common:
Don't invoke any actions in the clean_local and realclean_local
targets, since if using mmc --make, the builtin mmake rules
have actions for those targets as well, and make can't handle
more than one action for a target having actions. Replace those
actions with dependencies on other, unique targets that have
the actions instead.
tests/*/Mmakefile:
Avoid actions in clean_local and realclean_local targets the same way.
Sort the test names in some directories that didn't already do so.
Delete some obsolete comments.
Fix style.
tests/valid/Mmake.valid.common:
As for the Mmakefiles above, and also move the definition of a make
variable before it is needed.
tests/Mmake.common:
Replace the -j1 in the runtests_local target used by all the test
directories with $(MAYBE_J1).
tests/*/Mmakefile:
Define MAYBE_J1 it as the empty string in test directories in which
different tests don't share source files.
Define MAYBE_J1 as -j1 in test directories in which
different tests do share source files.
tests/submodules/sub2_a.m:
Add this copy of sub_a.m to allow tests in the submodules directory
to be done in parallel.
tests/submodules/accessibility2.m:
Import sub2_a.m instead of sub_a.m.
tests/warnings/ambig_types_high_level.m:
Add this copy of ambig_types.m to allow tests in the warnings directory
to be done in parallel.
tests/warnings/ambig_high_level.m:
Import ambig_types_high_level.m instead of ambig_types.m.
This file-specific setting will override a default setting of expandtabs
in $HOME/.vimrc.
*/Makefile:
*/Mmakefile:
As above.
tests/hard_coded/.gitignore:
Don't ignore the purity subdir. This ignore must have been left over
from when purity.m was a test in hard_coded, not hard_coded/purity,
and it ignored an executable, not a directory.
This warning is for when X is ground. When X is free (or otherwise nonground),
such unifications have always gotten an error.
compiler/mode_errors.m:
Add a warning type for occur check violations with ground vars.
Fix the grammar in the other two warnings generated by mode analysis.
compiler/modecheck_unify.m:
Generate the new warning when appropriate.
To make this possible, rewrite a previously 280-line predicate
that was hard to understand because of its structure as well as its
length into a smaller, better structured predicate less than half the size
(a) by moving coherent pieces of it out into other predicates,
some of which are now called more than once, thus reducing code
duplication, and (b) by avoiding redundant work, to wit, optimizing
the form of a unification when we have already decided that it has
a mode error, and thus cannot be scheduled now.
compiler/prog_mode.m:
Add a det version of an existing predicate.
compiler/inst_util.m:
Remove a comment on a predicate implementation that duplicates the
comment on the predicate's declaration.
compiler/modecheck_util.m:
Minor fixes of comments.
compiler/superhomogeneous.m:
Fix some bit rot: update the name of a predicate to match
the name of the data it works on, which was changed a few
years ago.
tests/invalid/occurs.err_exp:
tests/invalid/qualified_cons_id2.err_exp:
tests/warning/simple_code.exp:
tests/warning/unify_f_g.exp:
Conform to the error message format we generate after the change
to mode_errors.m.
tests/warning/unify_x_f_x.{m,exp}:
A new test case to test the new functionality.
tests/warning/Mmakefile:
Enable the new test case.
compiler/simplify_goal_disj.m:
Look for the conditions that lead to the bug (a disjunction that
further instantiates an already partially instantiated variable).
Generate an error message when found, PROVIDED that this happens
in a context in which the surrounding procedure can succeed
more than once. (If it cannot, then you cannot invoke an all-solutions
predicate on it, and the bug cannot happen.)
This condition (a model_non surrounding procedure) was motivated
by mdbcomp/feedback.m, which does not compile without it.
compiler/simplify_info.m:
The simplify_info type used to contain four different kinds of fields:
1 static fields; set and then never changed, such as the id of the
containing procedure
2 global information, such as the varset and vartypes, which are updated
as new variable are added, and whose updates need to be kept regardless
of what part of the procedure is analyzed next
3 information about the context surrounding the goal currently being
analyzed, such as the number of lambda expressions we are inside
4 information about the point in the code before the goal currently being
analyzed, such as the set of equivalences that currently hold between
variables (part of common_info).
The code of the simplify_goal*.m modules used to have jump through hoops
to handle 3 and 4 properly, given that the simplify_info was being
threaded through code in a way that was suitable only for 1 and 2.
This change takes categories 3 and 4 out of the simplify_info.
It creates a new type, simplify_nested_context, for category 3,
and adds information about the ability of the procedure surrounding
the current point to succeed more than once (needed for the bug311 fix)
to this new type.
compiler/simplify_tasks.m:
Rename the do_once task to mark_code_model_changes, since this
expresses what the task is much less ambiguously.
compiler/simplify_goal*.m:
compiler/simplify_proc.m:
compiler/common.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_llds_back_end.m:
Conform to the changes to simplify_info (and simplify_tasks).
Pass the current instmap and common_info (the two category 4 fields)
separately.
Mark some places that could be improved.
compiler/hlds_out_mode.m:
Generate easier-to-understand debugging output. I needed this to track
down a bug in my initial fix.
compiler/inst_match.m:
Remove a redundant unification that couldn't fail (since it was invoked
only if the exact same unification succeeded a few lines earlier).
Apply another minor optimizations.
compiler/instmap.m:
Remove references to the alias branch. It won't be coming back.
compiler/error_util.m:
Fix some documentation.
mdbcomp/feedback.m:
Put related stuff together.
tests/warnings/bug311.{m,err_exp}:
New test case for the bug.
tests/warnings/Mmakefile:
Enable the new test case.
Emit a warning if the variable that is the subject of a require_complete_switch
scope does not occur in the sub-goal.
compiler/det_report.m:
As above.
tests/valid/Mmakefile:
tests/valid/bug257b.{m,exp}:
tests/warnings/Mmakefile:
tests/warnings/bug257.{m,exp}:
Test cases for the above.
interface as unused even though the import is required in order to satisfy the
superclass constraints on an exported type class instance. (The situation
is explained in detail in the diff.)
The fix is to assume that when checking for unused modules, an imported module
that provides a type class instance is used. We can (and do) avoid this
assumption if the importing module does not export any type class instances
since in that case the erroneous warning cannot occur.
compiler/module_qual.m:
Keep tracking of which imported modules export type class instances
and whether the current module exports any.
Using the above information, avoid incorrectly reporting modules
imported in the interface as unused if they are in fact required
because of superclass constraints on instances.
(This is somewhat inelegant, but alternative fixes would require
either (a) delaying the unused module check until after the HLDS
has been constructed, or (b) doing more work on the parse tree
to make information about type class and instances available.
Both of these are much larger changes.)
tests/valid/Mercury.options:
tests/valid/Mmakefile:
tests/valid/bug100*.m:
Regression test for bug 100.
tests/warnings/Mmakefile:
tests/warnings/unused_interface_import*.m:
tests/warnings/unused_interface_import.exp:
Check that we still emit a warning about unused modules
that export instances if the module compiled does _not_
export any instances.
This checks the bodies of foreign_proc pragmas for possible errors.
Currently, these errors are:
(1) the presence of SUCCESS_INDICATOR (or in Java, succeeded),
in foreign procs. for predicates that cannot fail.
(2) the lack of SUCCESS_INDICATOR (succeeded) in foreign procs.
for predicates that can fail.
(3) the presence of "return" (or "ret" or "jmp" in IL). This could
indicate the presence of a return statement in the foreign proc.
Potentially, we could also check for the presence of the this
pointer in Java and C# foreign_procs, but that isn't implemented
at the moment.
The warning is disabled by default, since it will produce spurious
results if the things it checks for occur in foreign language
comments.
compiler/make_hlds_warn.m:
Implement the new warning.
Fix up another warning.
compiler/options.m:
Add the new option.
compiler/add_pragma.m:
compiler/pred_table.m:
Unrelated change: update some module qualifiers in a comment.
doc/user_guide.texi:
Document the new warning.
tests/warnings/Mercury.options:
tests/warnings/Mmakefile:
tests/warnings/warn_return.m:
tests/warnings/warn_return.exp*:
tests/warnings/warn_succ_id.m:
tests/warnings/warn_succ_id.exp*:
Test the output of the new warning.
Estimated hours taken: 24
Branches: main
Add a mechanism for generating warnings when the various clauses of a predicate
or function are not contiguous.
This mechanism consists of two options:
--warn-non-contiguous-clauses
--warn-non-contiguous-foreign-procs
The first option generates warnings when the Mercury clauses of a predicate
or function are not contiguous, but it ignores any foreign_procs of that
predicate or function, and thus allows these to be away from the Mercury
clauses and each other. This option is enabled by default.
The second option generating warnings unless both the Mercury clauses and
all the foreign_procs of the predicate or function are all contiguous.
This option is not enabled by default, because many library modules
group foreign_procs not by predicate, but by foreign language. (All C foreign
procs for a group of predicates, then all the Java foreign procs for that group
of predicates, etc.)
compiler/hlds_clauses.m:
Store, next to the representation of each clause list, information
about the locations (item numbers and context) of the clauses.
We store two versions of this information, one version for each option.
Make the predicates that access the clause list access the location
information as well, to ensure that any code that adds clauses also
records their location.
Add a predicate that tests for non-contiguity.
Add a specific type to represent the modes that a clause applies to.
This replaces the error-prone scheme we used to use that represented
the notion "this clause applies to all modes" with an empty list of
modes. This allows us to remove the code in add_pragma.m that used
to replace these empty lists with the list of actual modes they
represented.
Change the prefix on the fields of clauses_info to avoid ambiguities.
Add a prefix to the names of the function symbols of the clauses_rep
type to avoid ambiguities.
compiler/add_clause.m:
compiler/add_pragma.m:
When adding Mercury clauses and pragma foreign_procs to a predicate or
function, record the location of the clause or foreign_procs. We do so
even if the clause or foreign_proc is overridden by another. For
example, when compiling to C, a Mercury clause overrides an Erlang
foreign_proc, and a C foreign_proc overrides a Mercury clause.
Fix an old bug where a foreign_proc that should override Mercury
clauses overrode only one Mercury clause, and left the others
in the predicate, to yield a disjunction with some Mercury disjuncts
and a foreign_proc disjunct. This disjunction would then yield
determinism errors if it had outputs.
The new code that fixes the bug has a much more direct implicit
correctness argument, and should be significantly easier to understand.
It also avoids doing unnecessary work. (The old code could make a
decision to ignore a clause, yet still proceed to transform it,
just to ignore the result of the transformation.)
compiler/options.m:
Add the new options.
doc/user_guide.texi:
Document the new options. Fix an inconsistency between options.m and
user_guide.texi for a nearby option.
compiler/make_hlds_passes.m:
Pass the information that add_clause.m and add_pragma.m need.
compiler/typecheck.m:
Detect non-contiguous clauses and call typecheck_errors to generate
error messages.
compiler/typecheck_errors.m:
Add functions for formatting error messages about non-contiguous
clauses.
compiler/hlds_out.m:
Do not print the modes to which a clause applies for the usual case,
in which the clause applies to all modes.
compiler/clause_to_proc.m:
Simplify some code.
Rename a predicate to better reflect its purpose.
Conform to the changes above.
compiler/intermod.m:
Rename a predicate to avoid ambiguities.
Conform to the changes above.
compiler/add_class.m:
compiler/add_pred.m:
compiler/add_special_pred.m:
compiler/assertion.m:
compiler/build_mode_constraints.m:
compiler/dead_proc_elim.m:
compiler/dependency_graph.m:
compiler/goal_path.m:
compiler/headvar_names.m:
compiler/hhf.m:
compiler/higher_order.m:
compiler/hlds_pred.m:
compiler/implementation_defined_literals.m:
compiler/mode_constraints.m:
compiler/modes.m:
compiler/ordering_mode_constraints.m:
compiler/polymorphism.m:
compiler/post_typecheck.m:
compiler/proc_gen.m:
compiler/prop_mode_constraints.m:
compiler/purity.m:
compiler/type_constraints.m:
compiler/unify_proc.m:
compiler/unused_imports.m:
Conform to the changes above.
compiler/goal_form.m:
The new warnings pointed out a non-contiguous clause in goal_form.m.
Since this clause happened to be a duplicate of another clause, this
diff deletes it. The duplicate clause was not detected because the
predicate is semidet, and has no outputs.
compiler/mlds_to_c.m:
compiler/rbmm.points_to_analysis.m:
deep_profiler/measurements.m:
library/library.m:
library/list.m:
Fix non-contiguous clauses pointed out by the new warnings.
library/bit_buffer.m:
Fix programming style.
tests/invalid/types2.err_exp:
This test has non-contiguous clauses, so expect the new warning.
tests/warnings/warn_contiguous.{m,exp}:
tests/warnings/warn_non_contiguous.{m,exp}:
tests/warnings/warn_non_contiguous_foreign.{m,exp}:
tests/warnings/warn_non_contiguous_foreign_group.{m,exp}:
New test cases that exercise the new capability.
tests/warnings/Mmakefile:
tests/warnings/Mercury.options:
Enable and specify the options for the new tests.
Estimated hours taken: 0.2
Branches: main
tests/*/Mmakefile:
Sort the lists of tests in each directory. (We usually keep each list
sorted, but then we concatenate several lists, which loses the order.)
This gives you a better idea of how far a bootcheck still has to go.
tools/bootcheck:
Build the interface files before the rest of the files in the library
directory. Again, this gives you a better idea of how far a bootcheck
still has to go.
Make the dependencies for the slice subdirectory of the stage2 at the
same time as the other subdirs; don't let it be caught later.
library/Mmakefile:
Build the interface files in the right order.
Estimated hours taken: 0.1
Branches: main
tests/valid/trace_goal_dupl_defn.m:
Add a test case for the error message we get when a trace goal tries to
define something it shouldn't.
tests/valid/Mmakefile:
Note but don't enable the test case yet.
Estimated hours taken: 6
Branches: main
Issue a warning message if a user defined bound inst is not consistent with
any of the types in scope.
The warning needs to be disabled by default until all the Mercury machines
have been updated. This is because we will need to disable the warning for
the array module, since the following inst triggers the warning:
:- inst array(I) == bound(array(I)).
The problem is that there is no type with a function symbol array/1. I think
if we allow insts to be annotated with a type (as Zoltan suggested), then this
problem would go away, since we needn't check insts that are for foreign types.
NEWS:
Mention the new warning.
compiler/check_hlds.m:
Include the new module check_hlds.inst_check.
compiler/inst_check.m:
Implement a predicate that checks that all user defined insts
are consistent with at least one type in scope. The predicate
issues a warning if no consistent types are found for an inst.
compiler/mercury_compile.m:
Check insts at stage 12, before type and mode checking.
compiler/options.m:
Add an option to turn the new warning on or off.
compiler/notes/compiler_design.html:
Document the new module and compilation stage.
doc/user_guide.texi:
Document the option to disable the new warning.
tests/warnings/Mmakefile:
tests/warnings/Mercury.options:
tests/warnings/inst_with_no_type.m:
tests/warnings/inst_with_no_type.exp:
tests/warnings/inst_with_no_type_2.m:
Test the new warning.
Estimated hours taken: 1
Branches: main
Add a new option `--no-warn-obsolete' that disables warnings about calls to
predicates and functions that have `:- pragma obsolete' declarations.
Previously, this was controlled by `--no-warn-simple-code', but that was
non-obvious and you wouldn't necessarily want to disable all the other
warnings. `--no-warn-simple-code' will no longer disable warnings about
obsolete procedures.
Avoid emitting warnings for calls to obsolete procedures if those calls
are from within a procedure that is itself obsolete.
doc/user_guide.texi:
compiler/options.m:
Add a new option: `--no-warn-obsolete'.
tests/valid/Mmakefile:
tests/valid/Mercury.options:
tests/valid/no_warn_obsolete.m:
Test the new option.
compiler/simplify.m:
Don't warn about calls to obsolete procedures from obsolete
procedures.
tests/warnings/Mmakefile:
tests/warnings/spurious_obsolete.m:
tests/warnings/spurious_obsolete.exp:
Test case for the above.
Estimated hours taken: 2
Branches: main
Improve the formatting of some error messages by using error_util
and hlds_error_util to handle the formatting of the error messages.
compiler/error_util.m:
Add a new format component `quote', which is identical to `fixed'
except that it outputs it's argument surrounded by `' quotes.
compiler/add_clause.m:
compiler/add_type.m:
compiler/make_hlds_passes.m:
compiler/options_file.m:
compiler/qual_info.m:
compiler/stratify.m:
Use the error_util to format warning/error messages rather than
doing it manually.
compiler/passes_aux.m:
complier/hlds_out.m:
Update comments.
tests/invalid/errors.err_exp:
tests/invalid/errors1.err_exp:
tests/invalid/multimode_dcg.err_exp:
tests/invalid/multimode_syntax.err_exp:
tests/invalid/sub_c.err_exp:
tests/invalid/types.err_exp:
Update the expected outputs of these test cases to account
for formatting changes introduced by the above.
tests/warnings/Mmakefile:
tests/warnings/Mercury.options:
tests/warnings/non_stratification.{exp,m}:
Add a test case for the `--warn-non-stratification' option.
Estimated hours taken: 0.2
Branches: main
tests/warnings/Mmakefile:
Disable the `unused_args_analysis' test unless we are running under
`mmake --use-mmc-make'. Analysis files are only built by `mmc --make'
now, and caused this test to break under mmake.
tests/warnings/unused_args_analysis.exp2:
Add another expected output file for this test as `mmc --make' can
result in the warnings being written out twice.
Estimated hours taken: 4
Branches: main
tests/debugger/Mercury.options:
tests/valid/Mercury.options:
Use Mercury.options variables so that some module-specific
options work with `mmake --use-mmc-make' as well.
tests/invalid/Mmakefile:
tests/invalid/purity/Mmakefile:
Some ugly workarounds to get `mmake --use-mmc-make' to generate
.err files without aborting the entire make process and to
avoid doubled up error messages which `mmc --make' generates.
tests/warnings/Mmakefile:
`mmake --use-mmc-make' should pass the file to be made to `mmc --make'
as "unused_args_analysis.c", not "Mercury/cs/unused_args_analysis.c".
Estimated hours taken: 6
Branches: main
Don't just detect when successive unifications unify the same variable with
incompatible function symbols: also issue a warning.
compiler/ml_code_gen.m:
compiler/stratify.m:
compiler/table_gen.m:
mdbcomp/trace_counts.m:
Fix pieces of code that get the new warning.
compiler/modecheck_unify.m:
When detecting such unifications, add warnings for them, except if
the initial inst of the current restricts the set of allowed bindings
of the input arguments. If the initial inst of X is bound(f), then
an otherwise correct unification Y = g may fail if Y has been computed
from X. (We don't whether it has, so we have to be conservative.)
There are examples of such code in the library, e.g. functor in
deconstruct.m.
Factor out some common code.
compiler/mode_errors.m:
Add the infrastructure needed for printing warnings, and the two forms
of this warning in particular.
compiler/mode_info.m:
Extend the mode_info structure to make room for warnings, and for the
initial inst of the procedure arguments.
Switch to four-space indentation.
compiler/inst_util.m:
Add a predicate that tests whether an inst may restrict the set of
possible cons_ids a variable may be bound to.
Change the argument order of some predicates to allow them to be
used in higher order code. We don't need to make the switched-on
argument the first argument anymore.
Switch to four-space indentation.
compiler/hlds_goal.m:
Change the argument order of some predicates to allow the use of state
variables.
compiler/higher_order.m:
compiler/instmap.m:
compiler/mode_constraints.m:
compiler/mode_debug.m:
compiler/mode_ordering.m:
compiler/modecheck_call.m:
compiler/trace.m:
Conform to the changed argument orders described above.
Switch to four-space indentation.
compiler/common.m:
compiler/inst_match.m:
compiler/hlds_pred.m:
compiler/lambda.m:
compiler/magic.m:
compiler/magic_util.m:
compiler/modes.m:
compiler/pd_util.m:
compiler/post_typecheck.m:
compiler/unique_modes.m:
Conform to the changed argument orders described above.
tests/invalid/occurs.err_exp:
Expect the extra warning.
tests/warnings/Mmakefile:
Enable the unify_f_g test case I accidentally committed earlier.
tests/warnings/unify_f_g.{m,err_exp}:
Finalize that test case.
tests/warnings/simple_code.err_exp:
Expect the extra warning.
Estimated hours taken: 12
Branches: main
Remove most of the junk from the command lines executed by make when building
the compiler and by bootcheck when building test cases. We do this by moving
the junk into files consulted via the --flags option.
After this change, it is actually possible to see in a glance not just which
files are being compiled but also with which options. The size of the output
(measured in bytes) from a bootcheck is now only about 40% of what is was
before.
configure.in:
Remember the path to the bootstrap compiler and the flags it should be
invoked with separately. Put the flags into the FLAGS files in various
directories.
Test whether the default install directory actually exists, so that
the -L and -R linker options referring to this directory are passed
to the C compiler only if it does.
Mmake.common.in:
Comment out a bunch of additions of MCFLAGS, the ones whose contents
are now in FLAGS files.
Conform to the changes in configure.in.
Add a template rule for the dependencies of the FLAGS files.
Mmake.workspace:
Comment out a bunch of additions of MCFLAGS, the ones whose contents
are now in FLAGS files. In some cases, add references to the FLAGS
files.
Mmakefile:
When rebuilding Mmake.common, rebuild only Mmake.common, not all files
created by configure.
analysis/ANALYSIS_FLAGS.in:
browser/MDB_FLAGS.in:
compiler/COMP_FLAGS.in:
deep_profiler/PROF_FLAGS.in:
library/LIB_FLAGS.in:
mdbcomp/MDBCOMP_FLAGS.in:
profiler/DEEP_FLAGS.in:
slice/SLICE_FLAGS.in:
tests/TESTS_FLAGS.in:
Add these files, which each contain the junk flags (the flags which are
the same on every invocation and mostly just clutter up compiler
command lines) that are needed on each compiler invocation in the
relevant directory. Besides the results of configuration (word size
etc), and the paths to other parts of the system, these files mostly
control which warnings are enabled.
Restrict the list of directories in -I options to what is sensible;
for example, don't specify -I../analysis in the deep_profiler
directory.
*/.nocopyright:
Don't require copyright notices in FLAGS files, since that would make
them invalid.
library/INTER_FLAGS:
Add this file, which contains the flags enabled with intermodule
optimization.
tests/WS_FLAGS.ws:
Add this file. Unlike the .in files, which processed by config.status
based on the results of autoconfiguration, this one is processed to
specify the location of the workspace being tested.
analysis/Mmakefile:
browser/Mmakefile:
compiler/Mmakefile:
deep_profiler/Mmakefile:
library/Mmakefile:
mdbcomp/Mmakefile:
profiler/Mmakefile:
tests/Mmakefile:
Include the relevant directory's FLAGS file on the command line, to
replace all the additions to MCFLAGS in ../Mmake.common and in
../Mmake.workspace, and in some cases, the directory-specific Mmakefile
itself.
Build the directory's FLAGS file before executing the depend target,
since most compiler options beyond --generate-dependencies come from
there.
Delete the FLAGS files generated by config.status when doing "make
clean".
tests/Mmakefile:
Allow the environment to define DIFF_OPTS.
runtime/Mmakefile:
Use an option to tell config.status what to rebuild, not some
environment variables.
tests/invalid/Mercury.options:
For two test cases, reset an option that is set in tests/WS_FLAGS,
to match the options the affected tests were compiled with before.
tests/invalid/*.err2:
Update these expected files to account for the use of error_util
in error messages by previous changes to the compiler. These expected
output files are used only with --use-subdirs.
tests/warnings/Mmakefile:
For all test cases, reset an option that is set in tests/WS_FLAGS,
to match the options the tests were compiled with before.
scripts/prepare_tmp_dir_grade_part
Copy the flags files when creating the subdirectories of tmp_dir.
scripts/mgnuc.in:
Provide a mechanism, a per-directory .mgnuc_opts file, for specifying
the options that are required for every C file in a directory. The
intention is to use this for -I../library etc, but this is not done
yet; one thing at a time.
tools/bootcheck:
Copy the FLAGS files when creating stage2 and stage3.
Don't specify the compiler options that are now in FLAGS files.
Fill in the location of the workspace in tests/WS_FLAGS before running
the tests.
Provide a mechanism (a file ~/.bootcheck_diff_opts) to allow the user
to specify what options to invoke diff with.
Move the setting of MMAKE_USE_SUBDIRS and MMAKE_USE_MMC_MAKE after
we have built stage1, and always copy the profilers if --use-subdirs
is set. The old ways of doing things caused problems if bootcheck
was given --use-subdirs but stage1 doesn't use subdirs: the bootcheck
modified the stage1 slice, profiler and deep_profiler directories.
Estimated hours taken: 12
Branches: main
Replace the some() HLDS goal with a more general scope() goal, which can be
used not just for existential quantification but also for other purposes.
The main such purposes are new goal types that allow the programmer
to annotate arbitrary goals, and not just whole procedure bodies, with the
equivalents of promise_pure/promise_semipure and promise_only_solution:
promise_pure ( <impure/semipure goal> )
promise_semipure ( <impure goal> )
promise_equivalent_solutions [OutVar1, OutVar2] (
<cc_multi/cc_nondet goal that computed OutVar1 & OutVar2>
)
Both are intended to be helpful in writing constraint solvers, as well as in
other situations.
doc/reference_manual.texi:
Document the new constructs.
library/ops.m:
Add the keywords of the new constructs to the list of operators.
Since they work similarly to the "some" operator, they have the same
precedence.
compiler/hlds_goal.m:
Replace the some(Vars, SubGoal) HLDS construct, with its optional
keep_this_commit attribute, with the new scope(Reason, SubGoal)
construct. The Reason argument may say that this scope is an
existential quantification, but it can also say that it represents
a purity promise, the introduction of a single-solution context
with promise_equivalent_solutions, or a decision by a compiler pass.
It can also say that the scope represents a set of goals that all arise
from the unraveling of a unification between a variable and a ground
term. This was intended to speed up mode checking by significantly
reducing the number of delays and wakeups, but the cost of the scopes
themselves turned out to be bigger than the gain in modechecking speed.
Update the goal_path_step type to refer to scope goals instead of just
existential quantification.
compiler/prog_data.m:
Add new function symbols to the type we use to represent goals in items
to stand for the new Mercury constructs.
compiler/prog_io_goal.m:
Add code to read in the new language constructs.
compiler/prog_io_util.m:
Add a utility predicate for use by the new code in prog_io_goal.m.
compiler/make_hlds.m:
Convert the item representation of the new constructs to the HLDS
representation.
Document how the from_ground_term scope reason would work, but do not
enable the code.
compiler/purity.m:
When checking the purity of goals, respect the new promise_pure and
promise_semipure scopes. Generate warnings if such scopes are
redundant.
compiler/det_analysis.m:
Make the insides of promise_equivalent_solutions goals single solution
contexts.
compiler/det_report.m:
Provide mechanisms for reporting inappropriate usage of
promise_equivalent_solutions goals.
compiler/instmap.m:
Add a utility predicate for use by one of the modules above.
compiler/deep_profiling.m:
Use one of the new scope reasons to prevent simplify from optimizing
away commits of goals that have been made impure, instead of the old
keep_this_commit goal feature.
compiler/modes.m:
Handle from_ground_term scopes when present; for now, they won't be
present, since make_hlds isn't creating them.
compiler/options.m:
Add two new compiler options, for use by implementors only, to allow
finer control over the amount of output one gets with --debug-modes.
(I used them when debugging the performance of the from_ground_term
scope reason.) The options are --debug-modes-minimal and
--debug-modes-verbose.
compiler/handle_options.m:
Make the options that are meaningful only in the presence of
--debug-modes imply --debug-modes, since this allows more convenient
(shorter) invocations.
compiler/mode_debug.m:
Respect the new options when deciding how much data to print
when debugging of the mode checking process is enabled.
compiler/switch_detect.m:
Rename a predicate to make it differ from another predicate by more
than just its arity.
compiler/passes_aux.m:
Bring this module up to date with our current style guidelines,
by using state variable syntax where appropriate.
compiler/*.m:
Minor changes to conform to the change in the HLDS and/or parse tree
goal type.
mdbcomp/program_representation.m:
Rename the some goal to the scope goal, and the same for path steps,
to keep them in sync with the HLDS.
browser/declarative_tree.m:
Conform to the change in goal representations.
tests/hard_coded/promise_equivalent_solutions_test.{m,exp}:
A new test case to test the handling of the
promise_equivalent_solutions construct.
tests/hard_coded/Mmakefile:
Enable the new test.
tests/hard_coded/purity/promise_pure_test.{m,exp}:
A new test case to test the handling of the promise_pure and
promise_semipure constructs.
tests/hard_coded/purity/Mmakefile:
Enable the new test.
tests/invalid/promise_equivalent_solutions.{m,err_exp}:
A new test case to test the error messages for improper use of the
promise_pure and promise_semipure constructs.
tests/invalid/Mmakefile:
Enable the new test.
Estimated hours taken: 20
Branches: main
Improve the termination analyser's handling of user-defined
special predicates.
Currently termination analysis assumes that all calls
to special predicates terminate. For those that are
user-defined this is not necessarily true.
This diff adds a new pass to the compiler that is run after
the main termination analysis pass. It checks any user-defined
special predicates and emits a warning if their termination
can not be proved.
Add a new option, `--no-warn-non-term-special-preds' that
disables this warning. The warning is only emitted when
termination analysis is enabled. The new option has
no effect if termination analysis is not enabled.
compiler/post_term_analysis.m:
New file. Add an additional pass that runs after the main
termination analysis and makes use of the information obtained
then to perform further semantic checks and optimizations.
compiler/termination.m:
Run the new pass after the main analysis.
Update the comment about the termination analyser doing the
wrong thing for user-defined special predicates.
compiler/options.m:
Parse the new option.
Update the special handler for the inhibit_warning
option so that it handles `--warn-table-with-inline'
and the new option correctly.
Fix some typos.
compiler/transform_hlds.m:
Include the new module.
compiler/notes/compiler_design.html:
Mention the new module.
doc/user_guide.texi:
Document the new option.
Fix some typos: s/occured/occurred/,
s/interative/interactive/, s/exlained/explained/
and /currect/current/
library/array.m:
library/version_array.m:
Add pragma terminates declarations to the user-defined
equality and comparison predicates for the array/1
and version_array/1 types. The termination analyser
cannot (yet) prove termination in these cases because
it cannot reason about iteration over arrays.
tests/warnings/Mercury.options:
tests/warnings/Mmakefile:
tests/warnings/non_term_user_special.m:
tests/warnings/non_term_user_special.exp:
Test the new option.
Estimated hours taken: 2
Branches: main
Fix a problem where predicates that were tabled
but also had an inline pragma ended up being
exported in `.opt' files.
If these procedures were inlined in another
module the fact that they were tabled in the
original module was lost.
compiler/intermod.m:
Don't put tabled procedures in the `.opt' files even
if they have an inline pragma.
compiler/options.m:
compiler/make_hlds.m:
Emit a warning if a tabled procedure also has an
inline pragma. Add an option to suppress this
warning.
doc/user_guide.texi:
Document the new option.
tests/warnings/Mmakefile:
tests/warnings/table_with_inline.m:
tests/warnings/table_with_inline.exp:
Test case for the new warning.