mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-16 09:53:36 +00:00
b357a3dadcdf29c8d8ca184d65f7634a1a94de36
27 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
1457d825ee |
Fix more C# test failures.
tests/invalid_nodepend/Mercury.options:
tests/invalid_purity/Mercury.options:
Let several test cases proceed to the compiler invocation we want to test.
tests/submodules/impl_def_literal.m:
Comment out the atomic goal in this test case. (See below for the reason.)
tests/valid/big_foreign_type.m:
tests/valid/bug318.m:
tests/valid/flatten_conj_bug.m:
tests/valid/ho_and_type_spec_bug.m:
tests/valid/mert.m:
tests/valid/param_mode_bug.m:
These test cases were missing C# definitions (and in some cases,
Java definitions) of types and/or predicates. Add them.
tests/warnings/Mercury.options:
tests/warnings/Mmakefile:
Update references to a not-long-ago renamed file.
tests/warnings/foreign_singleton.m:
Add Java and C# definitions of some predicates.
tests/warnings/foreign_singleton.exp:
Update the line numbers in the expected output for C.
tests/warnings/foreign_singleton.exp[23]:
Add these expected output files for Java and C#.
compiler/simplify_goal.m:
Generate an error message if we find an atomic goal
but we are targeting a language which has no definitions
for the primitive operations used in the implementation of such goals.
Until now, for tests/submodules/impl_def_literal.m (which until now
contained an atomic goal), the compiler would generate code that
aborted at runtime. We report the problem, which avoids the generation
of code that would abort.
|
||
|
|
a0d6710407 |
Use "ts=4 sw=4 expandtab" as modeline ...
... in Mercury.options files. |
||
|
|
d4e7cde83e | Update tests/invalid_purity/purity.m. | ||
|
|
b843d53a4c |
Improve actual/expected mismatch diagnostics.
compiler/typecheck_errors.m:
Improve the diagnostics we generate for mismatches between actual and
expected types. If the mismatch was between a single actual type and
a single expected type, we already printed a message whose format
was specialized for that case, but in every other case, we fell back
to a more general but less readable error message template. Improve on this
by splitting the task into two halves, one for the actual type(s) and one
for the expected type(s), each of which generates simpler text if
there is only one such type.
Separate the actual type part of the diagnostic from the expected type part
using a semicolon instead of a comma, because we now use commas to
separate multiple actual types from each other, and multiple expected
types from each other.
Don't insist on putting a newline after the "type error:" part of the
diagnostic.
Do all of the above in just one predicate, factoring out code that
used to be duplicated.
Delete a function that has never been used. (I added it around 2008
for later use by a student working on software transactional memory,
but that use never happened.) This used to contain a third copy
of the code that was factored out.
For functions that used to take both a typecheck_info and a
type_error_clause_context, delete the latter argument, since the caller
invariably took it out of the typecheck_info that it also passed.
compiler/typecheck.m:
Don't pass now-unneeded type_error_clause_contexts.
compiler/typecheck_error_type_assign.m:
Fix typo in a field name.
tests/invalid/abstract_eqv.err_exp:
tests/invalid/actual_expected.err_exp:
tests/invalid/actual_more_expected.err_exp:
tests/invalid/bug197.err_exp:
tests/invalid/ext_type_bug.err_exp:
tests/invalid/fbnf.err_exp:
tests/invalid/foreign_procs_exist_type.err_exp:
tests/invalid/higher_order_mode_mismatch.err_exp:
tests/invalid/integral_constant_no_suffix.err_exp:
tests/invalid/method_impl.err_exp:
tests/invalid/mixed_up_streams.err_exp:
tests/invalid/try_bad_params.err_exp:
tests/invalid/type_diff.err_exp:
tests/invalid/type_error_ambiguous.err_exp:
tests/invalid/types2.err_exp:
tests/invalid_nodepend/errors2.err_exp:
tests/invalid_purity/impure_pred_t1_fixed.err_exp:
tests/invalid_purity/impure_pred_t2.err_exp:
tests/invalid_purity/purity_nonsense.err_exp:
tests/invalid_purity/purity_nonsense2.err_exp:
Update expected error messages.
|
||
|
|
0f75764e41 |
Pinpoint more actual/expected type differences.
compiler/typecheck_errors.m:
When there is a difference between actual and expected types
in predicate calls, do not just print the actual and expected types,
but if possible, point out the specific part(s) that cause the difference.
For example, report differences in arities, purity, determinism etc.
Also point out cases where the code is trying to specify the value
of an existentially quantified type variable.
When higher order types are printed as part of an error message,
strip any builtin qualifiers not just from the names of types,
but also from the names of the argument modes.
Start each part of an actual/expected pair at the same level of
indentation.
compiler/error_util.m:
Add a way to print out small integers as english names (one, two etc)
instead as numerals (1, 2 etc).
Add a way to print out purity descriptions.
Add a component, treat_next_as_first, that specifies that the next
format_component should be treated as the first part of a sentence
with respect to (de)capitalization by lower_next_if_not_first,
even if it is preceded by other format_components in a message.
This is useful in cases where the code that generates part of an
error message does not know whether that part will end up at the start
of the sentence, as the
<preceding sentence, ending in a period>
treat_next_as_first <context> lower_next_if_not_first, Words ...
sequence will keep Words capitalized if <context> is empty,
but will decapitalize it if <context> is not empty.
Rename {qual,unqual}_pf_sym_name_orig_arity as
{qual,unqual}_pf_sym_name_pred_form_arity, since this is clearer.
compiler/prog_out.m:
Apply the same s/orig_arity/pred_form_arity/ rename to some functions.
compiler/module_qual.qual_errors.m:
Fix an unrelated problem I came across while working on the changes above:
stray spaces at the ends of words(...) format_components, which screwed up
some error messages.
Simplify the description of classes and predicates by using facilities
in error_util.m that did not yet exist when this code was converted
to use error_util.m.
compiler/prog_type.m:
When stripping builtin qualifiers from types, strip them from the
modes stored in the higher_order inst into of higher order types as well,
for the same reason: to eliminate clutter in error messages.
Make the strip_kind_annotation function return a value that
shows in its type that the result will *not* be a kinded_type.
THIS IS THE FIRST USE OF SUBTYPES IN THE COMPILER.
compiler/type_assign.m:
Fix a long-standing documentation problem.
The type_assign type has long had a field named ta_external_type_params,
whose type was external_type_params, which was defined as equivalent
to a list of type variables. The name does not say what kinds of type
variables it contains, but the only two places that add type vars to
this field add type vars that are existentially quantified, either
by a predicate, or a cons_id. This diff therefore renames this field
to ta_existq_tvars, and changes its type to be just plain list(tvar).
(The external_type_params type has no documentation, so it may be used
to store different kinds of type variables in different places,
some of which may *not* be existentially quantified. Using the same name
for different purposes may be confusing.)
compiler/add_clause.m:
compiler/add_foreign_proc.m:
compiler/add_pragma_tabling.m:
compiler/add_pragma_type_spec.m:
compiler/add_pred.m:
compiler/check_promise.m:
compiler/check_typeclass.m:
compiler/convert_parse_tree.m:
compiler/hhf.m:
compiler/hlds_desc.m:
compiler/hlds_out_util.m:
compiler/make_hlds_error.m:
compiler/make_hlds_warn.m:
compiler/mark_tail_calls.m:
compiler/module_qual.qualify_items.m:
compiler/post_typecheck.m:
compiler/pred_table.m:
compiler/typecheck.m:
compiler/typecheck_debug.m:
compiler/typeclasses.m:
Conform to the changes above.
tests/invalid/fbnf.{m,err_exp}:
The motivating test case for this diff, slightly modified
from the code posted to m-users.
tests/invalid/type_diff.{m,err_exp}:
A test case to test the parts of the new code in typecheck_errors.m
that are not covered by other tests.
tests/invalid/Mmakefile:
Enable the new test cases.
tests/invalid/ext_type_bug.{m,err_exp}:
Extend this test case to test the pinpointing of errors that try to bind
existentially quantified type variables, at both the top level
and nested inside other type constructors.
tests/invalid/bug197.err_exp:
tests/invalid/higher_order_mode_mismatch.err_exp:
tests/invalid_purity/impure_pred_t1_fixed.err_exp:
tests/invalid_purity/impure_pred_t2.err_exp:
tests/invalid_purity/purity_nonsense.err_exp:
tests/invalid_purity/purity_nonsense2.err_exp:
Expect pinpointed type differences in these error messages.
tests/invalid/abstract_eqv.err_exp:
tests/invalid/integral_constant_no_suffix.err_exp:
tests/invalid/method_impl.err_exp:
tests/invalid/mixed_up_streams.err_exp:
tests/invalid/try_bad_params.err_exp:
tests/invalid/type_error_ambiguous.err_exp:
tests/invalid/types2.err_exp:
tests/invalid_nodepend/errors2.err_exp:
Expected updated formatting in these error messages.
|
||
|
|
bc1bf0470f |
Get type_to_pieces to generate structured output.
compiler/error_util.m:
Rewrite the type_to_pieces function, which typecheck_errors.m uses
to format types in error messages, in order to fix five problems.
The first two problems were with formatting higher order types.
First, if a higher order type included an existentially quantified
type variable, that quantification was *not* printed around the
higher order type. Second, that quantification *was* printed around
the type of every (non-higher-order) argument of the higher order value.
The only reason why this has not been a problem so far is that
we have no test case that contains a higher order type with an
existentially quantified type variable :-(
The fix to both these problems is to always put the existential
quantification of any such type variables at the top level, regardless
of the kind of type the quantification ranges over, and to never print
any quantification of any of its component types.
The third problem was that non-higher-order types were output in a
non-structured fashion. (The special-case code we used to format
higher order types did already output *them* in a structured fashion,
though only at the top level.) We did this by converting (unparsing)
the type to a term, and then calling mercury_term_to_string.
Generating structured output by replacing only the mercury_term_to_string
part would not worked well; most of the code would have been devoted
to working out what kind of type the given term was representing.
Therefore this diff changes the approach to formatting types without
converting them to a term. The output we generate for each type
uses indentation levels to show the type's structure, but for
types whose formatted form is sufficiently short, we delete all
the newlines from that representation.
The fourth problem was while most of the existing code took care
to treat function names as unbreakable, one part of it did not,
which caused the name of a field update function, "f1 :=",
to be split across two lines. This diff fixes that bug as well.
A fifth problem, pointed out by Peter, was that we were printing
arity-0 functions as "func" instead of as "(func)", even though
Mercury syntax for types demands the latter.
An arguable sixth problem was that we formatted existential
quantifications as
(some [Vars] Type)
We now format that as
some [Vars] (Type)
Change the order of the arguments of type_to_pieces to reduce
the difference between it and type_pieces, its internal version,
which we use to format types that do not need existential quantification.
Export the function that filters newlines out of lists of format
components, since other parts of the compiler may also need it
in the future.
Fix two occurrences of a bug that is totally unrelated to the above:
list_to_pieces and strict_list_to_pieces treated the last element
in their input list differently from all the other elements.
compiler/parse_tree_out_term.m:
Add a utility function for use by new code in error_util.m.
compiler/typecheck_errors.m:
Conform to the new argument order of type_to_pieces.
tests/invalid/actual_expected.err_exp:
tests/invalid/bug197.err_exp:
tests/invalid/ext_type.err_exp:
tests/invalid/ext_type_bug.err_exp:
tests/invalid/foreign_procs_exist_type.err_exp:
tests/invalid/higher_order_mode_mismatch.err_exp:
tests/invalid/ho_type_arity_bug.err_exp:
tests/invalid/no_method.err_exp:
tests/invalid/nullary_ho_func_error.err_exp:
tests/invalid/overloading.err_exp:
tests/invalid/type_error_ambiguous.err_exp:
tests/invalid/type_mismatch.err_exp:
tests/invalid/types2.err_exp:
tests/invalid/user_field_access_decl_override2.err_exp:
tests/invalid_purity/impure_func_t5.err_exp:
tests/invalid_purity/impure_pred_t1.err_exp:
tests/invalid_purity/impure_pred_t1_fixed.err_exp:
tests/invalid_purity/impure_pred_t2.err_exp:
Expect types in error messages in their updated format.
|
||
|
|
29ff7d5732 |
Improve diagnostics for type- and mode-errors.
compiler/mode_errors.m:
When generating an error message for a bad higher order inst,
print the specific cause of the mismatch, instead of just
"actual inst is X, expected inst was Y".
compiler/modecheck_call.m:
Change the code that generates that error to record the specific cause
in the mode_error structure of the error.
tests/invalid/higher_order_mode_mismatch.{m,err_exp}:
Add a new test case for the specific causes that other test cases
don't already cover. (As it happens, most of those causes can't be
caught by mode analysis because typechecking reports them first,
but it did so in ways that could be improved. Hence the change to
typecheck_errors.m and most of the .err_exp files below.)
tests/invalid/Mmakefile:
Enable the new test case.
compiler/typecheck_errors.m:
Instead of generating output of the form
<something> has type `abc',
expected type was `def'
generate output of the form
<something> has type
abc,
expected type was
def
The indentation directs the eye to the differences that matter,
and automatically lines up any corresponding parts of the actual
and expected types. It also replaces the quotes as a method
of separating the types being referred to from their surroundings.
tests/invalid/abstract_eqv.err_exp:
tests/invalid/actual_expected.err_exp:
tests/invalid/anys_in_negated_contexts.err_exp:
tests/invalid/arg_permutation.err_exp:
tests/invalid/bad_statevar_bad_context.err_exp:
tests/invalid/bug197.err_exp:
tests/invalid/comparison.err_exp:
tests/invalid/error_in_list.err_exp:
tests/invalid/ext_type.err_exp:
tests/invalid/ext_type_bug.err_exp:
tests/invalid/foreign_procs_exist_type.err_exp:
tests/invalid/getopt_old.err_exp:
tests/invalid/ho_type_arity_bug.err_exp:
tests/invalid/ho_type_mode_bug.err_exp:
tests/invalid/illtyped_compare.err_exp:
tests/invalid/integral_constant_no_suffix.err_exp:
tests/invalid/method_impl.err_exp:
tests/invalid/mixed_up_streams.err_exp:
tests/invalid/mpj1.err_exp:
tests/invalid/mpj4.err_exp:
tests/invalid/no_method.err_exp:
tests/invalid/nullary_ho_func_error.err_exp:
tests/invalid/overloading.err_exp:
tests/invalid/record_syntax_errors.err_exp:
tests/invalid/try_bad_params.err_exp:
tests/invalid/type_error_ambiguous.err_exp:
tests/invalid/type_error_in_arg.err_exp:
tests/invalid/type_mismatch.err_exp:
tests/invalid/types2.err_exp:
tests/invalid/user_field_access_decl_override2.err_exp:
tests/invalid_nodepend/errors2.err_exp:
tests/invalid_purity/impure_func_t5.err_exp:
tests/invalid_purity/impure_pred_t1.err_exp:
tests/invalid_purity/impure_pred_t1_fixed.err_exp:
tests/invalid_purity/impure_pred_t2.err_exp:
tests/invalid_purity/purity_nonsense2.err_exp:
tests/invalid_purity/purity_type_error.err_exp:
Expect the updated error messages.
tests/invalid/ho_type_mode_bug.m:
Update obsolete comments.
|
||
|
|
adf6c55847 |
Shut up mmake actions for check_namespace.
This reduces the size of the output of tools/bootcheck by 3700+ lines,
or about 25%.
Mmake.common.in:
Don't print the actions implementing namespace cleanliness checks.
To allow the attribution of any violations of the namespace rules,
print the name of the C module before any list of detected
nonallowed symbols.
To avoid mmake printing the actions for creating the .o files
that some of the check_namespace actions later check, rename
the affected object files .pseudo_o files, so that we can specify
a rule for them that is a copy of the rule for .o files, differing
only in not printing the compilation command.
Mark the files involved in check_namespace actions as dependencies
of .SECONDARY, which means that mmake does not automatically delete them
after building them as intermediate files. The reason for this is that
there is no way to tell make to delete intermediate files *silently*,
i.e. without writing out the rm command that deletes them.
To make up for this, tools/bootcheck now cleans up each directory
immediately after "mmake check_namespace" with "mmake clean_check",
which invokes mmake rules that do not print the rm commands.
This change does have the effect that these intermediate files *will*
hang around if the check_namespace target is every invoked manually.
However,
- we just about never run check_namespace in a directory manually, and
- when we do, a simple "mmake clean_check" will do the required cleanup.
scripts/Mmake.rules:
Move the vim tag line to its usual place at the top.
Replace old-school rules such as .m.err with their modern equivalents
(such as %.err: %.m).
scripts/Mmakefile:
Instead of printing the rules that make test_mdbrc, print only a
"making test_mdbrc" message.
runtime/Mmakefile:
Conform to the change of the name of a make variable in Mmake.common.in.
ssdb/Mmakefile:
Fix an old bug that something else in this diff tickled: make the
.depend target of each main module depend on SSDB_FLAGS, *not* just
the phony general "depend" target. This was a bug because tools/bootcheck
- copied across to stage 2 ONLY SSDB_FLAGS.in, and NOT SSDB_FLAGS,
- did NOT explicitly make SSDB_FLAGS from SSDB_FLAGS.in, even though
pretty much invocations of the Mercury compiler in this directory
have "--flags SSDB_FLAGS" as an implicit argument, and then
- built dependencies in the ssdb directory by invoking the top
Mmakefile's dep_ssdb target, which (indirectly) invokes
$(SSDB_LIB_NAME).depend.
Due to all the above, I don't actually know how tools/bootcheck
could ever build stage2/ssdb until now :-(
tools/bootcheck:
Invoke "mmake clean_check" after each "mmake check_namespace".
Change the code that explicitly builds the directory-specific
X_FLAGS file in each directory (which is invoked only when using
mmc --make) to actually build all such files, when previously
it built only a subset.
tests/invalid/Mmakefile:
tests/invalid_nodepend/Mmakefile:
tests/invalid_onlydepend/Mmakefile:
tests/invalid_options_file/Mmakefile:
tests/invalid_purity/Mmakefile:
tests/invalid_submodules/Mmakefile:
tests/stm/Mmakefile:
Fix an unintended consequence of replacing the .m.err rule in
scripts/Mmake.rules with %.err: %.m, which is that the %.err: %.m
rules in these mmakefiles became ineffective, because they appear
in the makefile we construct *after* the rule in scripts/Mmake.rules,
which specify a different action (the rules here return a nonzero
status in the *absence* of failure, which would be ridiculous
for the rule in scripts/Mmake.rules). Apparently, the %.err: %.m rules
overrode the rule in scripts/Mmake.rules while it had the old form,
but do not do so now it has the new form.
The fix is to make replace all the "%.err: %.m" rules in these Mmakefiles
with "$(PROGS:%=%.err): %.err: %.m" rules, which specify that they
override the generic rule for the .err files of the test cases
in each directory.
In invalid_purity/Mmakefile, fix a bug: -nodepend suffixes make sense
in only in the name of a *test*, not the name of a *program*, so
move such a suffix from a program name to a test name. Without this,
the program's .err file would be included in the list of .err files
to which the ".err: .m" rule applies under the wrong name.
In invalid_submodules/Mmakefile, fix the misleading names of some
make variables, and fix a misspelt directory name.
Standardize on "$(PROGS:%=%.err)" notation, replacing earlier instances
of "$(addsuffix .err,$(PROGS))". The reason for this is that when I tried
using "$addsuffix .int_err,$(PROGS))" in tests/invalid/invalid_make_int,
it did not work. (A google search on "gnu make addsuffix" did not yield
any clues as to why. Maybe you can only add suffixes that do not contain
underscores?)
|
||
|
|
a9c2e88cab |
Improve diagnostics for type mismatches.
compiler/typecheck_errors.m:
Improve diagnostics for some type errors in two separate ways.
First, when printing an error message for a type mismatch,
replace messages of the form
... has type T1,
expected type was T2
with messages of the form
... has type
T1,
expected type was
T2.
This way, the types both (a) stand out from the rest of the message,
and (b) any corresponding parts will line up, making discrepancies
easier to see.
Second, avoid messages of the form
... has type `some [T] T'
expected type was `some [T] T'.
which can be both baffling and infuriating, by including the variable
numbers of the type variables if this is needed to make two different
types *visibly* different, yielding messages such as
... has type
`some [T_2] T2',
expected type was
`some [T_3] T3'.
which can still be baffling, in the absence of any info about where T_2
and T_3 came from, but at least should not be infuriating, since it
*does* show a difference between actual and expected.
compiler/error_util.m:
Provide the infrastructure for the second part, by letting callers
control how type variables are printed.
tests/invalid/actual_expected.err_exp:
tests/invalid/bug197.err_exp:
tests/invalid/coerce_ambig.err_exp:
tests/invalid/ext_type_bug.err_exp:
tests/invalid/foreign_procs_exist_type.err_exp:
tests/invalid_purity/impure_pred_t1_fixed.err_exp:
tests/invalid_purity/impure_pred_t2.err_exp:
tests/invalid_purity/purity_nonsense.err_exp:
tests/invalid_purity/purity_nonsense2.err_exp:
Expect the updated error messages.
|
||
|
|
88047bbb45 |
Delete Erlang from tests.
tests/general/float_test.exp3:
tests/general/float_test.m:
tests/general/read_dir_regression.exp4:
tests/general/read_dir_regression.m:
tests/hard_coded/remove_file.exp2:
tests/hard_coded/remove_file.m:
Delete Erlang backend specific expected outputs.
tests/hard_coded/Mmakefile:
tests/hard_coded/erlang_deconstruct.exp:
tests/hard_coded/erlang_deconstruct.m:
tests/hard_coded/existential_list.exp:
tests/hard_coded/existential_list.m:
tests/valid/Mmakefile:
tests/valid/erl_ite_vars.m:
tests/valid/zf_erlang_bug.m:
Delete erlang target specific tests.
tests/*:
Delete Erlang foreign procs and foreign types.
|
||
|
|
f52d2381cc |
Make pred/func types more readable in error messages.
Until now, mismatches between expected and actual types, when they were
higher order types, got reported like this (the motivating example):
handle_options.m:158: In clause for predicate `process_given_options'/8:
handle_options.m:158: in argument 3 of functor `option_ops_userdata/3':
handle_options.m:158: type error in unification of argument
handle_options.m:158: and constant `special_handler'.
handle_options.m:158: argument has type `pred(libs.options.option,
handle_options.m:158: getopt_io.special_data,
handle_options.m:158: tree234.tree234(libs.options.option,
handle_options.m:158: getopt_io.option_data),
handle_options.m:158: getopt_io.maybe_option_table(libs.options.option),
handle_options.m:158: UserDataType, UserDataType)',
handle_options.m:158: constant `special_handler' has type
handle_options.m:158: `pred(libs.options.option, getopt_io.special_data,
handle_options.m:158: tree234.tree234(libs.options.option,
handle_options.m:158: getopt_io.option_data),
handle_options.m:158: getopt_io.maybe_option_table(libs.options.option))'.
This is hard to read
- because there is no visual break between the expected and the actual type,
and
- because the different initial prefixes before the starts of the types
prevent corresponding argument types in the expected and actual types
from lining up.
compiler/typecheck_errors.m:
Fix the above by always putting the argument types of higher order values
on lines of their own in such error messages. One side effect of this is
that we don't wrap predicate types in parentheses. (The parentheses' job
is to prevent unwanted interactions with surrounding code, but in
error messages, there *is* no surrounding code.)
Reorder the argument lists of some predicates and functions
to let them be used as the first argument of list.map.
compiler/parse_tree_to_term.m:
Delete a predicate that duplicates another predicate.
tests/invalid/ho_type_arity_bug.{m,err_exp}:
A new test case for the updated error message format.
tests/invalid/Mmakefile:
Enable the new test case.
tests/invalid/bug197.err_exp:
tests/invalid/nullary_ho_func_error.err_exp:
tests/invalid/type_error_ambiguous.err_exp:
tests/invalid/types2.err_exp:
tests/invalid_purity/impure_func_t5.err_exp:
tests/invalid_purity/impure_pred_t1.err_exp:
tests/invalid_purity/impure_pred_t1_fixed.err_exp:
tests/invalid_purity/impure_pred_t2.err_exp:
tests/invalid_purity/purity_nonsense.err_exp:
tests/invalid_purity/purity_nonsense2.err_exp:
Expect updated error messages.
|
||
|
|
1f45f91886 |
Make "mmake runtests" work again.
My commit |
||
|
|
afe2887882 |
Remove stale references to test subdirs.
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.
|
||
|
|
3a1ed2efcb |
Replace simple_call_id with pf_sym_name_arity.
compiler/prog_data.m:
Delete the simple_call_id data type, since it is isomorphic
to the pf_sym_name_arity type, which more clearly specifies
what is stored inside it.
compiler/prog_out.m:
Rename (all three versions of) simple_call_id_to_string to
pf_sym_name_orig_arity_to_string, both to conform to the change
in the input data type, and to emphasize that the resulting string
will contain the *original* arity of functions (which does not include
the return value), which is one less than the arity in the
pf_sym_name_arity structure (which, in accordance with the
convention inside the compiler that the arity is the length
of the argument list, *does* include the return value).
Delete the provision inside simple_call_id_to_string, now
pf_sym_name_orig_arity_to_string, for special handling of the names
of the predicates we use to implement promises, because it seems that
*none* of the call sites to any of the three versions of this function
can actually pass to it the identity of such a predicate. These calls
refer to a predicate or mode declaration item (which promise predicates
do not have), to clause or foreign_proc items (which again, promise
predicates cannot have) or calls to the predicate (promise predicates
cannot be called).
Delete the exported predicate simple_call_id_to_sym_name_arity.
It was called from exactly one place, inside prog_out.m itself,
and this diff inlines that call.
Avoid unnecessary forwarding of work from prog_out.m to error_util.m.
Delete (all three versions of) write_simple_call_id. The changes
below replace all their (few) uses with calls to
pf_sym_name_orig_arity_to_string.
compiler/error_util.m:
Replace the simple_call() error piece with qual_pf_sym_name_orig_arity,
and add a new version unqual_pf_sym_name_orig_arity. Their names
explicitly say that they print the original arities of functions,
also say whether they strip away any module qualification on the
sym_name inside the pf_sym_name_arity. We prefer the unqual version
in situations where the module qualifier is implicit, which usually means
that it must be the same as the name of the module being compiled, because
it reduces visual clutter for readers of error messages.
Put {qual,unqual}_pf_sym_name_orig_arity next to their most closely
related function symbols, {qual,unqual}_sym_name_arity, in the
format_component type. (This yields a few inconsequential changes
in the order of error_specs when sorted.)
compiler/add_class.m:
compiler/add_clause.m:
compiler/add_foreign_proc.m:
compiler/add_pragma.m:
compiler/add_pragma_tabling.m:
compiler/add_pragma_type_spec.m:
compiler/add_pred.m:
compiler/check_libgrades.m:
compiler/check_parse_tree_type_defns.m:
compiler/check_promise.m:
compiler/check_typeclass.m:
compiler/convert_parse_tree.m:
compiler/equiv_type.m:
compiler/goal_expr_to_goal.m:
compiler/hlds_data.m:
compiler/hlds_desc.m:
compiler/hlds_goal.m:
compiler/hlds_out_pred.m:
compiler/hlds_out_util.m:
compiler/hlds_pred.m:
compiler/inst_util.m:
compiler/llds_out_instr.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make_hlds_error.m:
compiler/make_hlds_warn.m:
compiler/mark_tail_calls.m:
compiler/ml_unify_gen_construct.m:
compiler/mlds_to_c_stmt.m:
compiler/mode_errors.m:
compiler/mode_info.m:
compiler/modecheck_util.m:
compiler/module_qual.collect_mq_info.m:
compiler/module_qual.qualify_items.m:
compiler/parse_item.m:
compiler/parse_module.m:
compiler/parse_type_repn.m:
compiler/polymorphism.m:
compiler/post_typecheck.m:
compiler/pre_quantification.m:
compiler/pred_table.m:
compiler/prog_item.m:
compiler/recompilation.version.m:
compiler/term_constr_build.m:
compiler/termination.m:
compiler/type_ctor_info.m:
compiler/typecheck.m:
compiler/typecheck_errors.m:
compiler/typecheck_info.m:
compiler/unify_gen_construct.m:
compiler/unused_imports.m:
Conform to the changes above. Where I am pretty sure that in an error
message, the module qualifier of a name must be the current module,
use unqual_pf_sym_name_orig_arity instead of qual_pf_sym_name_orig_arity.
Add some sanity checks where they seem appropriate.
Replace sequences of io.write_strings with uses of io.format where this
yields clearer code. (This is why there were no remaining calls to
write_simple_call_id.)
Shorten some too-long lines.
In add_pred.m, make the order of some predicate definitions match
the order of the calls to them.
tests/invalid/ambiguous_method.err_exp:
tests/invalid/ambiguous_method_2.err_exp:
tests/invalid/bad_pred_arity.err_exp:
tests/invalid/bad_sv_unify_msg.err_exp:
tests/invalid/bigtest.err_exp:
tests/invalid/bug113.err_exp:
tests/invalid/bug197.err_exp:
tests/invalid/bug278.err_exp:
tests/invalid/bug410.err_exp:
tests/invalid/bug476.err_exp:
tests/invalid/bug487.err_exp:
tests/invalid/complex_constraint_err.err_exp:
tests/invalid/constrained_poly_insts.err_exp:
tests/invalid/errors.err_exp:
tests/invalid/errors1.err_exp:
tests/invalid/errors2.err_exp:
tests/invalid/exported_mode.err_exp:
tests/invalid/field_syntax_error.err_exp:
tests/invalid/foreign_singleton.err_exp:
tests/invalid/funcs_as_preds.err_exp:
tests/invalid/imported_mode.err_exp:
tests/invalid/invalid_binary_literal.err_exp:
tests/invalid/invalid_float_literal.err_exp:
tests/invalid/invalid_hex_literal.err_exp:
tests/invalid/invalid_octal_literal.err_exp:
tests/invalid/make_opt_error.err_exp:
tests/invalid/missing_det_decls.err_exp:
tests/invalid/multimode_syntax.err_exp:
tests/invalid/null_char.err_exp:
tests/invalid/occurs.err_exp:
tests/invalid/record_syntax_errors.err_exp:
tests/invalid/ref_to_implicit_pred.err_exp:
tests/invalid/require_tailrec_1.err_exp:
tests/invalid/require_tailrec_1.err_exp2:
tests/invalid/require_tailrec_2.err_exp:
tests/invalid/require_tailrec_2.err_exp2:
tests/invalid/require_tailrec_3.err_exp:
tests/invalid/require_tailrec_3.err_exp2:
tests/invalid/state_vars_test2.err_exp:
tests/invalid/state_vars_test3.err_exp:
tests/invalid/state_vars_test5.err_exp:
tests/invalid/type_inf_loop.err_exp:
tests/invalid/typeclass_constraint_extra_var.err_exp:
tests/invalid/typeclass_mode_2.err_exp:
tests/invalid/typeclass_test_12.err_exp:
tests/invalid/typeclass_test_2.err_exp:
tests/invalid/typeclass_test_9.err_exp:
tests/invalid/types.err_exp:
tests/invalid/types2.err_exp:
tests/invalid/unbound_type_vars.err_exp:
tests/invalid/with_type.err_exp:
tests/invalid_purity/purity_nonsense.err_exp:
tests/invalid_purity/purity_nonsense2.err_exp:
tests/warnings/double_underscore.exp:
tests/warnings/pragma_source_file.exp:
tests/warnings/singleton_test.exp:
tests/warnings/singleton_test.exp2:
tests/warnings/singleton_test.exp3:
tests/warnings/singleton_test.exp4:
tests/warnings/singleton_test_state_var.exp:
tests/warnings/warn_return.exp:
tests/warnings/warn_return.exp2:
tests/warnings/warn_return.exp3:
tests/warnings/warn_succ_ind.exp:
tests/warnings/warn_succ_ind.exp2:
tests/warnings/warn_succ_ind.exp3:
tests/warnings/warn_succ_ind.exp4:
Update all these expected output files. Most changes are due to
predicate and function names no longer being module qualified when
the module qualification is obvious. A few changes are due to the
change in the relative ordering of the function symbols of the
format_component type.
For singleton_test, warn_return and warn_succ_ind in warnings,
the changes to the non-C .exp files were done by hand, so they
may have the wrong white space.
|
||
|
|
4aed1a57e4 |
Print an arg type list diff for arg lists with wrong arity.
When a user writes a clause for a predicate (or function) that does not exist
with that arity, but does exist with one or more other arities, report not
just the list of the other arity/arities, but, for each such other arity,
a diff between the declared arg types and the inferred arg types.
After this diff, we generate output like this:
bad_pred_arity.m:027: Error: clause for predicate `bad_pred_arity.p'/4
bad_pred_arity.m:027: without corresponding `:- pred' declaration.
bad_pred_arity.m:027: However, predicates of that name do exist with arities
bad_pred_arity.m:027: 3 and 5.
bad_pred_arity.m:027: Inferred :- pred p(int, string, int, string).
bad_pred_arity.m:027: The argument list difference from the arity 3 version
bad_pred_arity.m:027: is
bad_pred_arity.m:027: pred(
bad_pred_arity.m:027: int,
bad_pred_arity.m:027: + string,
bad_pred_arity.m:027: int,
bad_pred_arity.m:027: string
bad_pred_arity.m:027: )
bad_pred_arity.m:027: The argument list difference from the arity 5 version
bad_pred_arity.m:027: is
bad_pred_arity.m:027: pred(
bad_pred_arity.m:027: int,
bad_pred_arity.m:027: - float,
bad_pred_arity.m:027: string,
bad_pred_arity.m:027: int,
bad_pred_arity.m:027: string
bad_pred_arity.m:027: )
compiler/typecheck_errors.m:
Generate the diff part of the message above.
compiler/typecheck.m:
Invoke typecheck_errors.m when relevant.
compiler/error_util.m:
When comparing two error_specs, switch from a two-level comparison
(first the contexts of error_msgs, then everything else) to three levels
first the contexts of error_msgs, then their error_msg_components,
then everything else). This is needed to allow the error message from
make_hlds_error.m (which reports the error and mentions the arities
with which the named predicate or function does exist) come out before
the informational message from typecheck.m that prints the inferred
arg types and their differences from the other arities. (With the old
comparison, the difference in severity would trump the invisible order
components that this diff includes in both specs to force the desire
order.)
Base the code comparing error_specs on the code for comparing error_msgs.
Move the two previously separate pieces code for those tasks next to each
other.
compiler/make_hlds_error.m:
Add the invisble ordering component.
When we see clauses with two or more wrong arities for a given predicate
or function, don't list the automatically created pred declaration
for an *earlier* wrong-arity clause as a real declaration whose arity
is to be listed in the error messages we generate for *later* wrong-arity
clauses.
Add some documentation.
compiler/add_pred.m:
Factor out some common code.
library/edit_seq.m:
A new module for computing diffs.
library/library.m:
library/MODULES_DOC:
Add the new module to the standard library.
tests/hard_coded/edit_seq_test.{m,exp}:
A new test case for the diff algorithm.
tests/invalid/bad_pred_arity.{m,err_exp}:
A new test case for the new error message.
tests/hard_coded/Mmakefile:
tests/invalid/Mmakefile:
Enable the new test cases.
tests/invalid/bigtest.err_exp:
tests/invalid/bug197.err_exp:
tests/invalid/bug278.err_exp:
tests/invalid/errors2.err_exp:
tests/invalid/invalid_binary_literal.err_exp:
tests/invalid/invalid_float_literal.err_exp:
tests/invalid/invalid_hex_literal.err_exp:
tests/invalid/invalid_main.err_exp:
tests/invalid/invalid_octal_literal.err_exp:
tests/invalid/multimode_dcg.err_exp:
tests/invalid/multisoln_func.err_exp:
tests/invalid/null_char.err_exp:
tests/invalid/state_vars_test3.err_exp:
tests/invalid/try_detism.err_exp2:
tests/invalid/typeclass_test_5.err_exp:
tests/invalid/typeclass_test_8.err_exp:
tests/invalid/unsatisfiable_constraint.err_exp:
tests/invalid_purity/impure_func_t3.err_exp:
Update these files to expect error messages in the new order.
samples/diff/*.m:
Fix comments, mostly by moving them to where our programming style
wants them.
|
||
|
|
68f0bbf83a |
Improve error messages about missing predicates.
compiler/make_hlds_error.m:
When printing an error message about a predicate or function with
a given name and arity not being found, print the arities for which
there *is* a predicate or function with that name.
compiler/hlds_error_util.m:
Provide utility predicates to find the arities with which a name exists.
compiler/typecheck_errors.m:
Delete the code that is now one of the utility predicates in
hlds_error_util.m.
compiler/add_foreign_proc.m:
compiler/add_pragma.m:
compiler/add_pragma_type_spec.m:
When reporting that a foreign_proc or pragma specifies a nonexistent
predicate or function, tell make_hlds_error.m about the arities
that the programmer may have meant to put next to the pred or func name.
When generating error messages about something defined in the current
module, don't module qualify its name, since the message is unambiguous
without, and its presence is just clutter for readers.
In add_pragma.m, when printing an error message about the pragma being
added being incompatible with previous pragmas, specify their kinds.
compiler/hlds_pred.m:
Export the fact that the pred_markers type is implemented as a set.
In more than 20 years, we have never exploited the fact that this type
was abstract, and I don't think we would in the next 20 :-) The export
simplifies new code in add_pragma.m.
compiler/hlds_out_pred.m:
Add a comment reminding future updaters of some code of a requirement
placed on it by new code in add_pragma.m.
tests/invalid/bad_consider_used.err_exp:
tests/invalid/inline_conflict.err_exp:
tests/invalid/require_tailrec_invalid.err_exp:
tests/invalid/type_spec.err_exp:
tests/invalid_purity/purity_nonsense2.err_exp:
Expect error messages with the changes listed above.
|
||
|
|
fc4b3ff196 |
Remove .cvsignore files
Remove old .cvsignore files, moving their contents to .gitignore files. There are now no .cvsignore files in the repository. I've also sorted some .gitignore files and avoided repeating a pattern in a subdirectory's .gitignore file when it is already mentioned in the parent .gitignore file. |
||
|
|
5fe4e36b71 |
Enable invalid_purity/pragma_c_and_mercury.
tests/invalid_purity/pragma_c_and_mercury.m:
Fix the XXX regarding foreign code definitions that was preventing this
from working.
Fix the placement of the mode declarations.
tests/invalid_purity/pragma_c_and_mercury.err_exp:
Update line numbers in expected error.
Also, the compiler no longer omits the spurious message about extra
information being available if `-E' is given.
tests/invalid_purity/Mmakefile:
Enable the above test.
|
||
|
|
1ab13edca6 |
Switch over unary and binary ops in Java and C# code generators.
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.
|
||
|
|
ef6d68a88d |
Add items to the HLDS by kinds, not in passes.
There are several reasons for this change.
First, it is more flexible than the previous arrangement of adding items
to the HLDS in three passes. Since adding a fourth pass would have had
significant performance implications, we refrained from making changes
that would have required a fourth pass in a pass-based algorithm.
With the new structure, such changes do not lead to any detectable slowdown,
so there is no reason why we should avoid making them.
In fact, the immediate motivation for this diff is to make such a change.
This is a fix for Mantis bug 318, which requires adding abstract and/or
non-foreign definitions for types before foreign definitions for those types
*regardless* of their relative order in the source code.
This diff also has the side effect that e.g. the mode declarations for
a predicate don't have to follow the declaration of the (type of) the predicate
itself. Pred and mode declarations used to be processed in the same pass,
but now, all pred declaration are processed before all mode declarations.
Second, as identified earlier, the new structure is conceptually cleaner than
the old one, and the constraints on when different kinds of items have to be
added to the HLDS can documented next to the code that does the adding,
since that code is no longer mixed with code that adds other kinds of items
at the same time.
Third, the code we used to use to detect invalid type definitions
was only a crude approximation. With the new setup, it is trivial to use
an exact computation. We now proceed to later compiler passes in many cases
that previously led us to stop before type checking because we (erroneously)
believed that the program had an invalid type definition.
Fourth, my benchmarking shows a speedup on tools/speedtest -l -m of about
1.2% to 1.5%. The new approach does allocate a bit more memory (a pair
and a cons cell per item), but it traverses most items just once, not
three times. A few kinds of items (e.g. pred declarations) do have to be
processed more than once, e.g. both before and after some other kinds
of items are added to the HLDS, but four of the five most frequent items
in bootchecks (the pragmas recording the results of the termination and
exception analyses, mode declarations, and clauses) are processed just once.
Evidently, the speedup from traversing fewer items, and avoiding the
switches on item kinds that those traversals involve, is greater than
the extra cost of the additional memory allocations, including their effect
on garbage collection times.
compiler/make_hlds_passes.m:
Make the change described above.
Remove "shim" code, i.e. code that serves only to unpack the pairing
of an item with other info such as a status, and code that tests
that status, e.g. to see whether the item is defined in the module
being compiled. Move that shim code to the other submodules of
make_hlds.m. (We used to have add_xyz predicate in make_hlds_passes.m
and module_add_xyz predicates in those submodules, in which add_xyz
contained only shim code and a call to the corresponding module_add_xyz
predicate.)
compiler/add_class.m:
compiler/add_mutable_aux_preds.m:
compiler/add_pred.m:
compiler/add_solver.m:
Move shim code here from make_hlds_passes.m.
Give some predicates better names.
In a few cases, remove unneeded arguments from predicates. For example,
most predicates that do only checks don't need write access to the
module_info.
compiler/add_pragma.m:
Use subtypes to make the code a bit more efficient.
Add specialized fold predicates that can handle those subtypes.
compiler/add_type.m:
Add documentation for an old design decision.
compiler/make_hlds.m:
Add some utility types for use by make_hlds_passes.m and the various
add_xyz.m.
compiler/check_typeclass.m:
Improve an error message. We now get this error message even for modules
on which the compiler previously stopped before getting to typechecking.
compiler/modes.m:
Don't generate redundant error messages for mode errors in mutables' aux
preds. (Previously, the mode checker wouldn't have been invoked if
make_hlds_passes.m found the original problem.)
compiler/prog_item_stats.m:
Delete an unneeded import.
library/list.m:
Add an inst-preserving version of reverse, since make_hlds_passes.m
now needs one.
tests/debugger/solver_test.exp:
We add predicates to the HLDS in a different order now (auxiliary
predicates for solver types are added *after* used-defined predicates).
This test prints the raw order of those predicates, so expect the new
order.
tests/invalid/typeclass_test_9.err_exp:
tests/invalid_purity/purity_nonsense2.err_exp:
Expect error messages we didn't used to get, because the compiler
stopped before typechecking due to (incorrectly) believing that it found
an invalid type definition.
For typeclass_test_9, expect the updated error message from
check_typeclass.m. (This newly printed error message was the reason
*why* I improved the message from check_typeclass.m.)
tests/invalid/tc_err1.err_exp:
tests/invalid/tc_err2.err_exp:
tests/invalid/typeclass_bogus_method.err_exp:
tests/invalid/typeclass_missing_mode_2.err_exp:
tests/invalid/typeclass_test_10.err_exp:
tests/invalid/typeclass_test_3.err_exp:
tests/invalid/typeclass_test_4.err_exp:
Expect the updated error message from check_typeclass.m.
tests/valid/bug318.m:
A test case for Mantis bug 318.
tests/valid/Mmakefile:
Enable the new test case.
|
||
|
|
984683b267 |
Fix the invalid/func_class test case.
The failure was caused by an error message generated by prog_io.m about a
problem (a file containing the wrong module) being ignored by deps_map.m.
A different problem was that we detected and generated error messages for this
problem in several places, which had different expectations and had access
to different information, and (partially but not wholly as a result of that)
generated different text. This diff makes all the pieces of code that detect
this problem use the same code to generate an error message. (Having only
one place to *detect* the problem would be more trouble that it is worth;
it would replace a few simple pieces of code with one larger, more complex
piece of code that would still have to cover all the relevant use cases,
but now removed from the rest of the code handling those use cases as well.)
It would probably be a good idea to unify those use cases as much as possible,
but that would be a much more complex change.
compiler/prog_io.m.m:
Generalize the predicate that generates error messages for wrong module
names, check_module_has_expected_name, to make it usable from both
prog_io.m and read_modules.m.
Replace a piece of code that had the same job with a call to this
predicate.
compiler/read_modules.m.m:
When reading in source files, ignore the errors that arise from
trying to read nonexistent files if our caller asks us to do so
(since some callers are not sure about what file a module is stored in),
but if the file *is* found and opened, then do *not* ignore the
errors we generate in parsing its contents.
Call the generalized version of check_module_has_expected_name,
and pass it the info it needs (the context of the module declaration).
compiler/deps_map.m:
If the read-in module contains a different module name than expected,
we already generated an error message for it, which read_modules.m
now doesn't throw away, so we now just keep that message,
and don't generate a redundant one.
compiler/error_util.m:
When sorting error messages, we have, for a long time now, deleted
duplicates. However, two error messages can differ in one having
conditional inclusion of format components and the other always
including the same components. We don't want to get two copies
of the error message if the condition is true, so we now evaluate
the conditions before sorting the messages. This is needed because
the code in prog_io.m that generates error messages for wrong module names
has to work in different conditions that have different ideas of how
bad an error a wrong module name is.
Provide a mechanism (a new phase in error messages) to separate
error messages about wrong module names from other errors.
This was part of an earlier attempt at solving the same problem
using a different approach (generating a new error message about
the problem only if we haven't already generated a message about it),
but that approach had the problem that the text of the generated message
could differ if it was generated in more than place, making it hard
to write a good test case. (Hence the generalization of
check_module_has_expected_name: although in some situations it generates
unconditional and in other condition error messages, the text in those
messages is always the same.) However, the new phase doesn't hurt
anything, and may be useful later, e.g. to handle modules like
tests/invalid_purity/purity_nonsense2.m differently, so keep it.
tests/invalid/Mmakefile:
Execute the purity_nonsense2 test case without first generating its
dependencies. If we did generate its dependencies, then due to the
fact that we no longer ignore errors during that step, we would
get *only* those errors, and not also the ones discovered by parts
of the compiler invoked later, and which are also expected by
purity_nonsense2.err_exp.
tests/invalid/bad_module_name.err_exp:
Expect the updated text of the "wrong module name" error message.
tests/invalid/missing_interface_import2.{m,err_exp}:
Due to a missing :- interface declaration, this test case wasn't testing
what it was testing. Add the missing section marker, and expect the updated
line numbers.
tools/bootcheck:
Print an explicit message at the end of a successful bootchecks.
|
||
|
|
8a764392d9 |
Avoid warnings from make in test directories.
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.
|
||
|
|
62ec97d443 |
Report imports shadowed by other imports.
If a module has two or more import_module or use_module declarations
for the same module, (typically, but not always, one being in its interface
and one in its implementation), generate an informational message about
each redundant declaration if --warn-unused-imports is enabled.
compiler/hlds_module.m:
We used to record the set of imported/used modules, and the set of
modules imported/used in the interface of the current module. However,
these sets
- did not record the distinction between imports and uses;
- did not allow distinction between single and multiple imports/uses;
- did not record the locations of the imports/uses.
The first distinction was needed only by module_qual.m, which *did*
pay attention to it; the other two were not needed at all.
To generate messages for imports/uses shadowing other imports/uses,
we need all three, so change the data structure storing such information
for *direct* imports to one that records all three of the above kinds
of information. (For imports made by read-in interface and optimization
files, the old set of modules approach is fine, and this diff leaves
the set of thus *indirectly* imported module names alone.)
compiler/unused_imports.m:
Use the extra information now available to generate a
severity_informational message about any import or use that is made
redundant by an earlier, more general import or use.
Fix two bugs in the code that generated warnings for just plain unused
modules.
(1) It did not consider that a use of the builtin type char justified
an import of char.m, but without that import, the type is not visible.
(2) It scanned cons_ids in goals in procedure bodies, but did not scan
cons_ids that have been put into the const_struct_db. (I did not update
the code here when I added the const_struct_db.)
Also, add a (hopefully temporary) workaround for a bug in
make_hlds_passes.m, which is noted below.
However, there are at least three problems that prevent us from enabling
--warn-unused-imports by default.
(1) In some places, the import of a module is used only by clauses for
a predicate that also has foreign procs. When compiled in a grade that
selects one of those foreign_procs as the implementation of the predicate,
the clauses are discarded *without* being added to the HLDS at all.
This leads unused_imports.m to generate an uncalled-for warning in such
cases. To fix this, we would need to preserve the Mercury clauses for
*all* predicates, even those with foreign procs, and do all the semantic
checks on them before throwing them away. (I tried to do this once, and
failed, but the task should be easier after the item list change.)
(2) We have two pieces of code to generate import warnings. The one in
unused_imports.m operates on the HLDS after type and mode checking,
while module_qual.m operates on the parse tree before the creation of
the HLDS. The former is more powerful, since it knows e.g. what types and
modes are used in the bodies of predicates, and hence can generate warnings
about an import being unused *anywhere* in a module, as opposed to just
unused in its interface.
If --warn-unused-imports is enabled, we will get two separate set of
reports about an interface import being unused in the interface,
*unless* we get a type or mode error, in which case unused_imports.m
won't be invoked. But in case we do get such errors, we don't want to
throw away the warnings from module_qual.m. We could store them and
throw them away only after we know we won't need them, or just get
the two modules to generate identical error_specs for each warning,
so that the sort_and_remove_dups of the error specs will do the
throwing away for us for free, if we get that far.
(3) The valid/bug100.m test case was added as a regression test for a bug
that was fixed in module_qual.m. However the bug is still present in
unused_imports.m.
compiler/make_hlds_passes.m:
Give hlds_module.m the extra information it now needs for each item_avail.
Add an XXX for a bug that cannot be fixed right now: the setting of
the status of abstract instances to abstract_imported. (The "abstract"
part is correct; the "imported" part may not be.)
compiler/intermod.m:
compiler/try_expand.m:
compiler/xml_documentation.m:
Conform to the change in hlds_module.m.
compiler/module_qual.m:
Update the documentation of the relationship of this module
with unused_imports.m.
compiler/hlds_data.m:
Document a problem with the status of instance definitions.
compiler/hlds_out_module.m:
Update the code that prints out the module_info to conform to the change
to hlds_module.m.
Print status information about instances, which was needed to diagnose
one of the bugs in unused_imports.m. Format the output for instances
nicer.
compiler/prog_item.m:
Add a convenience predicate.
compiler/prog_data.m:
Remove a type synonym that makes things harder to understand, not easier.
compiler/modules.m:
Delete an XXX that asks for the feature this diff implements.
Add another XXX about how that feature could be improved.
compiler/Mercury.options.m:
Add some more modules to the list of modules on which the compiler
should be invoked with --no-warn-unused-imports.
compiler/*.m:
library/*.m:
mdbcomp/*.m:
browser/*.m:
deep_profiler/*.m:
mfilterjavac/*.m:
Delete unneeded imports. Many of these shadow other imports, and some
are just plain unneeded, as shown by --warn-unused-imports. In a few
modules, there were a *lot* of unneeded imports, but most had just
one or two.
In a few cases, removing an import from a module, because it *itself*
does not need it, required adding that same import to those of its
submodules which *do* need it.
In a few cases, conform to other changes above.
tests/invalid/Mercury.options:
Test the generation of messages about import shadowing on the existing
import_in_parent.m test case (although it was also tested very thoroughly
when giving me the information needed for the deletion of all the
unneeded imports above).
tests/*/*.{m,*exp}:
Delete unneeded imports, and update any expected error messages
to expect the now-smaller line numbers.
|
||
|
|
73f0a36719 |
Allow the use of -jN in many test directories.
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.
|
||
|
|
fdd141bf77 |
Clean up the tests in the other test directories.
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.
|
||
|
|
de2f7b2a0c |
Flatten the test directories, step 2.
Specifically, rename the following subdirectories of the test directory:
old dir name new dir name
analysis/ext analysis_external
analysis/ctgc analysis_ctgc
analysis/excp analysis_excp
analysis/table analysis_table
analysis/trail analysis_trail
invalid/purity invalid_purity
analysis/sharing analysis_sharing
hard_coded/purity purity
general/accumulator accumulator
analysis/unused_args analysis_unused_args
debugger/declarative declarative_debugger
hard_coded/exceptions exceptions
general/string_format string_format
hard_coded/sub-modules submodules
hard_coded/typeclasses typeclasses
general/structure_reuse structure_reuse
Some subdirectories are still there, to wit, the subdirs of the inactive
test directory stm, each of which (if I remember correctly) holds only one
test case.
The general/structure_reuse directory previously wasn't enabled; I think
this was a bug.
tests/Mmakefile:
tools/bootcheck:
List the new test directories.
tests/Mmake.common:
The analysis_* directories each need to know whether the workspace
uses subdirs. This used to be controlled from one place,
analysis/Mmakefile, but since analysis_* are not subdirs of analysis,
we need a new central place to find this out.
tests/analysis/common.sh:
Update documentation for the move.
tests/OLDDIRS/Mmakefile:
Set the subdir list to empty.
tests/NEWDIRS/Mmakefile:
Update the "this" directory's name, as well as TESTS_DIR.
In analysis_*/Mmakefile, use the new mechanism for detecting the presence
of subdirs.
|
||
|
|
d9a1050af6 |
Flatten the test directories, step 1.
Specifically, rename the following subdirectories of the test directory:
old dir name new dir name
analysis/ext analysis_external
analysis/ctgc analysis_ctgc
analysis/excp analysis_excp
analysis/table analysis_table
analysis/trail analysis_trail
invalid/purity invalid_purity
analysis/sharing analysis_sharing
hard_coded/purity purity
general/accumulator accumulator
analysis/unused_args analysis_unused_args
debugger/declarative declarative_debugger
hard_coded/exceptions exceptions
general/string_format string_format
hard_coded/sub-modules submodules
hard_coded/typeclasses typeclasses
general/structure_reuse structure_reuse
Some subdirectories are still there, to wit, the subdirs of the inactive
test directory stm, each of which (if I remember correctly) holds only one
test case.
The general/structure_reuse directory previously wasn't enabled; I think
this was a bug.
tests/Mmakefile:
tools/bootcheck:
List the new test directories.
tests/Mmake.common:
The analysis_* directories each need to know whether the workspace
uses subdirs. This used to be controlled from one place,
analysis/Mmakefile, but since analysis_* are not subdirs of analysis,
we need a new central place to find this out.
tests/analysis/common.sh:
Update documentation for the move.
tests/OLDDIRS/Mmakefile:
Set the subdir list to empty.
tests/NEWDIRS/Mmakefile:
Update the "this" directory's name, as well as TESTS_DIR.
In analysis_*/Mmakefile, use the new mechanism for detecting the presence
of subdirs.
|