mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-18 02:43:40 +00:00
083d376e6598628362ee91c2da170febd83590f4
169 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
307b1dc148 |
Split up error_util.m into five modules.
compiler/error_spec.m:
This new module contains the part of the old error_util.m that defines
the error_spec type, and some functions that can help construct pieces
of error_specs. Most modules of the compiler that deal with errors
will need to import only this part of the old error_util.m.
This change also renames the format_component type to format_piece,
which matches our long-standing naming convention for variables containing
(lists of) values of this type.
compiler/write_error_spec.m:
This new module contains the part of the old error_util.m that
writes out error specs, and converts them to strings.
This diff marks as obsolete the versions of predicates that
write out error specs to the current output stream, without
*explicitly* specifying the intended stream.
compiler/error_sort.m:
This new module contains the part of the old error_util.m that
sorts lists of error specs and error msgs.
compiler/error_type_util.m:
This new module contains the part of the old error_util.m that
convert types to format_pieces that generate readable output.
compiler/parse_tree.m:
compiler/notes/compiler_design.html:
Include and document the new modules.
compiler/error_util.m:
The code remaining in the original error_util.m consists of
general utility predicates and functions that don't fit into
any of the modules above.
Delete an unneeded pair of I/O states from the argument list
of a predicate.
compiler/file_util.m:
Move the unable_to_open_file predicate here from error_util.m,
since it belongs here. Mark another predicate that writes
to the current output stream as obsolete.
compiler/hlds_error_util.m:
Mark two predicates that wrote out error_spec to the current output
stream as obsolete, and add versions that take an explicit output stream.
compiler/Mercury.options:
Compile the modules that call the newly obsoleted predicates
with --no-warn-obsolete, for the time being.
compiler/*.m:
Conform to the changes above, mostly by updating import_module
declarations, and renaming format_component to format_piece.
|
||
|
|
50c3301737 |
Simplify some code in error_util.m.
compiler/error_util.m:
Interpret each context just once per error_msg, not once per line.
Add the fixed indent after the context, creating a prefix string,
just once per error_msg, not once per line.
Compute the length of the prefix directly from the prefix string,
instead of counting the characters that go into its components.
Don't print out the line-specific indent on blank lines.
Replace a quadratic algorithm with a linear one.
For each line we output, record the total length of its words,
and the total length available for those words. This prepares
for a future change that will try to replace several lines, even if
they ended with "nl" pieces, with one,
- if the result fits in the available space, and
- if the text of the lines indicates this is desirable.
compiler/hlds_out_util.m:
compiler/prog_out.m:
Move the code for writing out indents from hlds_out_util.m to prog_out.m.
We now want to call it from error_util.m, and it does not depend on the
HLDS at all.
tests/invalid/anys_in_negated_contexts.err_exp:
tests/invalid/ho_default_func_1.err_exp:
tests/invalid/ho_default_func_3.err_exp:
tests/invalid/ho_type_mode_bug.err_exp:
tests/invalid/modes_erroneous.err_exp:
tests/invalid_nodepend/errors2.err_exp:
tests/warnings/inconsistent_pred_order.exp:
tests/warnings/subtype_order.exp:
Don't expect the line-specific indent on blank lines.
|
||
|
|
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.
|
||
|
|
07f877bc3f |
Carve term_context.m out of term.m.
library/term.m:
library/term_context.m:
As above.
Rename the term.context type as term_context.term_context, with
term.context now being defined as an equivalence type.
Replace the context_init function and predicate and the dummy_context_init
function with just one function: dummy_context. This name includes
the important part (the fact that it return a *dummy* context) and deletes
the nonimportant part (dummy contexts are just about never updated,
so the function does not really "initialize" them).
Reduce function/predicate pairs that do the same thing to just a function.
library/MODULES_DOC:
library/library.m:
Add the new module to the list of standard library modules.
NEWS:
Mention the new module, and the obsoleting of the moved predicates
and functions in term.m.
compiler/*.m:
library/*.m:
Conform to the changes above.
|
||
|
|
f7355f708b |
Move var_db and var_{name,type}_source to var_db.m.
In the process, restrict the use of these types to just those modules
that need to provide services both other modules that use var_tables,
and modules that do not. The latter are modules that either can,
or always do, execute before var_tables are set up.
In some cases, code that previously operated on e.g. var_name_sources
had all its callers converted to use var_tables. In those cases, replace
the use of var_name_sources with var_tables directly.
In other cases, code that previously operated on e.g. var_name_sources
still has some callers that use varsets. In those cases,
- provide versions using var_tables if most callers use var_tables,
renaming predicates/functions to make this the version seem the default,
- leave the operation to work on var_name_sources if some its callers
also have only var_name_sources,
- if there are no such callers, keep just the two versions operating
on varsets and var_tables respectively.
compiler/var_db.m:
compiler/var_table.m:
Move the part of var_table.m that contains the definitions
of the above three types, and the operations on them, to the
new module var_db.m. Only 25 modules currently need var_db.m,
compared to 176 for var_table.m.
compiler/parse_tree.m:
compiler/notes/compiler_design.html:
Add and document the new module.
compiler/parse_tree_out_term.m:
Add a "_vs" suffix to the names of operations that print variables
or terms using varsets, and reuse their old names for versions
that use var_table arguments. For the operations that need var_name_source
versions, make it just select between the varset and var_table versions.
compiler/hlds_out_goal.m:
compiler/instmap.m:
compiler/hlds_out_mode.m:
compiler/hlds_out_util.m:
compiler/hlds_pred.m:
compiler/pd_info.m:
Change some predicates that used to operate on var_{name,type}_sources
to operate on var_tables.
In hlds_out_mode.m, delete some unused predicates, and stop exporting
a predicate whose only caller is local.
compiler/*.m:
Conform to the changes above.
|
||
|
|
02f0128c5a |
Use var_tables in more of the later passes.
compiler/add_heap_ops.m:
compiler/add_trail_ops.m:
compiler/float_regs.m:
compiler/lambda.m:
compiler/mark_tail_calls.m:
Convert these passes to use var_tables instead of varsets and vartypes.
compiler/hlds_pred.m:
Provide predicates to get and set "the var_table" of a procedure.
The proc_info still stores varsets and vartypes, but these new predicates
do the required conversions between representations. Likewise, provide
a version of proc_info_create that takes a var_table argument instead
of a varset and vartypes arguments. The new predicates should reduce
the need for such conversions to be done elsewhere during the transition.
compiler/var_table.m:
Provide a predicate to turn a var_table back into
a <varset, vartypes> pair.
Provide two transitional types, var_db and var_type_source, that
provide either
- the functionality of both a varset and a vartypes, or
- just the functionality of a vartypes,
using either those structure(s), or a var_table.
Make it possible to allocate new variables from a var_table,
by including in it a counter that takes on the role played by
the var_supply in varsets.
Provide a predicate to look up the types of several variables at once.
Provide a way to construct a var_table from a reverse sorted assoc list.
compiler/vartypes.m:
Provide a way to construct a var_table from a reverse sorted assoc list,
to allow code to operate the same way on vartypes as on var_tables.
library/varset.m:
Provide predicates to make the changes in var_table.m possible.
They have to be exported, but they are in the second interface section,
so they are not publicly documented.
compiler/quantification.m:
compiler/recompute_instmap_deltas.m:
compiler/goal_util.m:
Provide versions of some exported predicates that take var_tables
instead of varsets and vartypes, for use by the modules above.
Rationalize the argument order of some predicates.
compiler/instmap.m:
Generalize some existing predicates to take type information
from either vartypes or var_tables, using a transitional mechanism
now provided by var_table.m.
Rationalize the argument order of some predicates.
compiler/inlining.m:
Fix an unrelated bug that just happened to be tickled by the
rest of this diff. When inlining a call, set the flag that calls
for rerunning determinism analysis on the procedure in which the
inlining takes place if the call has an argument variable that
does not occur outside the call. We need to do this because
ignoring the last output argument(s) of a call can reduce
the max possible number of solutions of the call to one.
compiler/set_of_var.m:
Provide a predicate needed by the fix in inlining.m.
compiler/prog_type.m:
Give some predicates meaningful names, and create versions that
return the same info in a different form (set instead of list).
compiler/add_pragma_type_spec.m:
compiler/check_typeclass.m:
compiler/code_info.m:
compiler/continuation_info.m:
compiler/deforest.m:
compiler/error_util.m:
compiler/follow_code.m:
compiler/higher_order.m:
compiler/hlds_class.m:
compiler/hlds_rtti.m:
compiler/ml_gen_info.m:
compiler/old_type_constraints.m:
compiler/parse_class.m:
compiler/parse_type_defn.m:
compiler/pd_util.m:
compiler/polymorphism.m:
compiler/polymorphism_type_class_info.m:
compiler/post_typecheck.m:
compiler/push_goals_together.m:
compiler/qual_info.m:
compiler/saved_vars.m:
compiler/simplify_goal_disj.m:
compiler/simplify_goal_ite.m:
compiler/simplify_goal_switch.m:
compiler/simplify_proc.m:
compiler/size_prof.m:
compiler/table_gen.m:
compiler/trace_gen.m:
compiler/type_assign.m:
compiler/type_ctor_info.m:
compiler/typecheck.m:
compiler/typeclasses.m:
compiler/unneeded_code.m:
compiler/unused_args.m:
Conform to the changes above.
|
||
|
|
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.
|
||
|
|
3930b12636 | Break up a large predicate. | ||
|
|
dd632327db |
Generalize component_list_to_line_pieces.
compiler/error_util.m:
Do not automatically add an nl to the end of the output
of component_list_to_line_pieces; instead, let the callers specify
how the last line should end. Most will pass nl, but some will pass
an nl_indent_delta to undo an earlier nl_indent_delta.
compiler/add_clause.m:
compiler/add_foreign_enum.m:
compiler/add_mode.m:
compiler/add_pragma.m:
compiler/error_msg_inst.m:
compiler/post_typecheck.m:
compiler/prog_foreign_enum.m:
compiler/typecheck_errors.m:
Conform to the change in error_util.m.
|
||
|
|
243491523d |
Stop counting errors in module_infos.
Over time, we have almost completely switched over to using error_specs,
using their severity (if not yet printed out) and their effect on the
exit status (if already printed out) to represent the presence of errors,
leaving only a few places that either updated or paid attention to the
num_error field in the module_info. This diff completes that process.
compiler/hlds_module.m:
Delete the num_errors field in the module_info, and the predicates
that operate on it.
compiler/hlds_error_util.m:
Delete module_info arguments whose only purpose was to update the
now-delete field.
compiler/error_util.m:
Delete the old write_error_spec predicates that updated a count of warnings
and a count of errors.
Rename the write_error_spec_ignore predicates, which ignored those counts,
by deleting the "_ignore" from their names. This makes them take the
place of the deleted predicates.
compiler/add_pragma_type_spec.m:
compiler/add_pred.m:
compiler/add_type.m:
compiler/compile_target_code.m:
compiler/cse_detection.m:
compiler/find_module.m:
compiler/generate_dep_d_files.m:
compiler/handle_options.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.top_level.m:
compiler/make.track_flags.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_middle_passes.m:
compiler/mercury_compile_mlds_back_end.m:
compiler/mode_info.m:
compiler/modes.m:
compiler/pd_util.m:
compiler/pred_table.m:
compiler/recompilation.check.m:
compiler/typecheck.m:
compiler/write_module_interface_files.m:
Conform to the changes above.
|
||
|
|
1927c8ee21 |
Separate always_treat_as_first from treat_as_first.
compiler/error_util.m:
The internal operation of formatting error messages requires knowing
whether an error_msg should be treated as the first message, or not.
(First messages get indented 1 space; other messages get indented by 3.)
We use the treat_at_first type for this.
In the past, we also used this type in error_msgs themselves, but there,
one of the alternatives of the type, do_not_treat_as_first, is misleading.
Such messages will in fact be treated as first if they are in fact
the first error_msg in an error_spec, which happens quite frequently,
since *most* error_specs contain only one error_msg.
This diff therefore defines a new type, always_treat_as_first,
whose two values have names that *accurately* reflect their meaning:
always_treat_as_first, and treat_based_on_posn. Make all code outside
error_util.m itself use this type; restrict the use of the treat_as_first
type to just the code that does error message formatting.
compiler/add_class.m:
compiler/add_foreign_proc.m:
compiler/check_typeclass.m:
compiler/common.m:
compiler/compile_target_code.m:
compiler/compiler_util.m:
compiler/compute_grade.m:
compiler/fact_table.m:
compiler/find_module.m:
compiler/grab_modules.m:
compiler/handle_options.m:
compiler/make.top_level.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_mlds_back_end.m:
compiler/mode_errors.m:
compiler/modes.m:
compiler/options_file.m:
compiler/parse_module.m:
compiler/post_typecheck.m:
compiler/prog_event.m:
compiler/recompilation.check.m:
compiler/term_constr_errors.m:
compiler/term_errors.m:
compiler/typecheck_msgs.m:
compiler/write_module_interface_files.m:
Conform to the change in error_util.m. In many cases where this is
appropriate, use the recently introduced simplest_no_context_specs.
|
||
|
|
c2be367805 |
Return error_specs instead of doing printouts.
compiler/check_libgrades.m:
Replace some direct printouts of error messages with the error_specs.
compiler/make.program_target.m:
compiler/make.top_level.m:
Transmit these error specs to the level level, then print them out,
together with any other error specs, some of which have not been
converted from direct printouts to error specs yet.
In make.top_level.m, break up a too-large predicate.
compiler/error_util.m:
Add a form of simplest_spec that does not have an associated context,
for situations such as the above.
compiler/options_file.m:
Make the interface of a predicate less error prone.
compiler/mercury_compile_main.m:
compiler/mode_errors.m:
Conform to the changes above.
|
||
|
|
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.
|
||
|
|
8f50e16eb2 |
Fix a possible silent failure when making .int files.
When I split two files in a recent change, I ran into an annoying problem.
The problem was caused by unneeded imports in the interface of the new modules,
whose initial part I originally simply copied from the source module.
The problem was that when I attempted to compile new module A which imported
new module B, the compilation of module A would fail with a message about
not finding module B's .int file. It couldn't find B.int because the
compiler invocation that was supposed to create it failed, but it did not
print any error message about *why* it failed, and as a consequence,
it also did not set the exit status to nonzero to tell mmake that
the file was not actually built, so later build actions that need that file
should not be executed.
The cause of this problem was the following.
- The default value of the --warn-unused-imports is off, but COMP_FLAGS
turns it on for modules in the compiler directory. This enables warnings
generated by unused_imports.m.
- There is code that does a similar job in module_qual.qual_errors.m, but
that one is limited to imports in interface sections. Due to the overlap
between tasks, when this code finds an unused import_module declaration
in an interface, it generates an error message that was conditional
on --warn-unused-imports being off. When it was on, as it is with
COMP_FLAGS, it generates an error_spec that, when given to write_error_specs,
generates no output.
- Code in write_module_interface_files.m that decided whether the building
of the .int file has failed, tested only whether the process of generating
its contents has returned any error_specs, not whether it returned
any error_specs that would actually be printed, and, by being printed
with a sufficiently high severity, would set the exit status to signal
failure.
compiler/error_util.m:
The two changes to this file together fix the root cause of this problem.
First, a new predicate checks whether an error_spec has any part
whose printing is NOT disabled by being attached to an unmet condition.
Second, the predicate through which we pass all error_specs created
during the generation of the contents of the .int file filters out
any error_specs that yield no output.
The later changes are not strictly part of the bugfix, they are there
simply to make the code simpler to understand, in the hope that this fact
will reduce the probability of similar problems in the future.
compiler/module_qual.qual_errors.m:
Instead of generating error_specs that are conditional on
--warn-unused-imports being OFF, generate them conditional on
the new option --warn-unused-interface-imports being ON.
Using --warn-unused-imports here was strange because that option controls
whether the compiler invokes unused_imports.m. It was NOT specific
to this piece of code, while the new option is.
compiler/options.m:
doc/user_guide.texi:
Add the new option. Comment out its documentation, since I don't think
I can describe the reason for its existence simply enough for users
to understand.
compiler/handle_options.m:
Turn off the new option --warn-unused-interface-imports if
--warn-unused-imports is set. This duplicates the old behavior
of module_qual.qual_errors.m.
Turn off the new option --warn-unused-interface-imports if
we are generating interface files. This is because the presence
of unneeded imports in .m files does not prevent the creation
of valid .int files, so having to fix such warnings at .int file
creation time interferes with the programmer's ability to choose
the order in which he/she works on getting modules to a compilable shape.
compiler/write_module_interface_files.m:
Generate all output on error as part of an error_spec.
compiler/unused_imports.m:
Fix indentation.
tests/valid_make_int/extra_interface_import.m:
A new test case for this bug.
tests/valid_make_int/Mmakefile:
Enable the new test case.
|
||
|
|
8827b6a466 |
Make --halt-at-invalid-interface the default.
NEWS:
Mention this fact.
Group related changes together.
Fix some typos.
compiler/error_util.m:
Let the halt_at_invalid_interface option govern whether we print error
messages when we generate .int/.int2 files, rather than
the print_errors_warnings_when_generating_interface option.
This simplifies the use of that option.
compiler/options.m:
doc/user_guide.texi:
Document the halt_at_invalid_interface option.
Delete the print_errors_warnings_when_generating_interface option,
since its functionality has been subsumed into halt_at_invalid_interface.
compiler/grab_modules.m:
Check the accessibility of imported modules not just when generating target
language code, but also when generating .int/.int2 files. Without this,
the test_nested test case, which this diff moves from invalid to
invalid_make_int, would miss out on some errors being reported
in its new home.
To make the above possible, refactor the code that does the check
to let it work on aug_make_int_units as well as from aug_compilation_units.
Make the wording of any error message depend on where the info came from,
because unlike aug_comp_units, aug_make_int_units work with an
known-incomplete picture of the relevant info.
Update some obsolete comments.
compiler/write_module_interface_files.m:
Add a comment about a design decision that affects this diff.
tests/invalid_make_int/Mercury.options:
tests/invalid_make_int/Mmakefile:
Add to this directory's list the test cases that this diff moves
to this directory from other test directories, because the errors
that they test for are now reported at interface generation time.
Fix the rule handling multimodule tests, now that we have some :-(
Specify -j1 for this directory, since the two tests moved here
from invalid_submodules include nested submodules.
tests/invalid_make_int/bad_type_class_constraint_intermodule.{m,int_err_exp}:
Move this test case here from invalid, renaming files slightly,
and update the expected output.
tests/invalid_make_int/bug499.{m,int_err_exp}:
Move this test case here from invalid, and update the expected output.
tests/invalid_make_int/int_impl_imports.{m,int_err_exp}:
tests/invalid_make_int/int_impl_imports_2.m:
Move this test case here from invalid, and update the expected output.
tests/invalid_make_int/missing_interface_import2.{m,int_err_exp}:
tests/invalid_make_int/missing_interface_import3.m:
Move this test case here from invalid, and update the expected output.
tests/invalid_make_int/missing_parent_import.{m,int_err_exp}:
tests/invalid_make_int/children.m:
tests/invalid_make_int/children2.m:
Move this test case here from invalid_submodules,
and update the expected output.
tests/invalid_make_int/sub_c.{m,int_err_exp}:
tests/invalid_make_int/sub_a.m:
Move this test case here from invalid_submodules,
and update the expected output.
tests/invalid_make_int/test_nested.{m,int_err_exp}:
tests/invalid_make_int/parent.m:
tests/invalid_make_int/parent.private_child.m:
tests/invalid_make_int/parent.public_child.m:
tests/invalid_make_int/parent.undeclared_child.m:
tests/invalid_make_int/parent2.child.m:
tests/invalid_make_int/parent2.m:
Move this test case here from invalid, and update the expected output.
tests/invalid_make_int/transitive_import.{m,int_err_exp}:
Move this test case here from invalid, update it,
and update the expected output.
tests/invalid/Mmakefile:
Delete from the list of tests in this directory the tests
moved to invalid_make_int, and test bug521.
tests/invalid/bug521.{m,err_exp}:
tests/invalid/bug521_sub.m:
Delete this test. invalid_make_int already had a copy of the relevant
part of this test.
tests/invalid_submodules/Mmakefile:
Delete from the list of tests in this directory the two tests
moved to invalid_make_int.
Delete from the list of tests in this directory two other tests
for which we now detect some or all of the errors tested for
at interface generation time, but which are already covered
by other tests.
tests/valid_make_int/Mmakefile:
Delete from the list of tests in this directory the test
moved to invalid_make_int. (We could successfully generate
a .int file for that test case *only if* we did not check it
for errors :-)
tests/valid_seq/intermod_nested_module_bug2.m:
tests/valid_seq/intermod_nested_module_bug2.sub.m:
Move two module imports from the parent to the child module,
because only the child needs them, and any compiler with this diff
will now complain about them being unused in the parent
at interface generation time. Delete a third import, which was
not used anywhere.
|
||
|
|
d64961d79d |
Use checked types/insts/modes in parse_tree_module_src.
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
|
||
|
|
12605f8c10 |
Use checked type/inst/modes in parse_tree_int[123]s.
With this change, we guarantee that if any type, inst or mode
has inconsistent definitions in its defining module, those inconsistencies
will not make it into the the module's .int/.int2/.int3 files, where
they would confuse any compiler invocation that reads them in.
compiler/prog_item.m:
Replace {type,inst,mode}_ctor_defn_maps, which are unchecked,
with {type,inst,mode}_ctor_checked_maps in parse_tree_int[123]s.
To make this possible,
- generalize the items containing inst and mode definitions the way that
items containing type definitions have been generalized previously,
to allow them to store particular *kinds* of inst or mode definitions;
- move the definitions of type_ctor_checked_map and its components
here from check_type_inst_mode_defns.m; and
- add similar, but simpler, definitions for {inst,mode}_ctor_checked_map.
compiler/check_type_inst_mode_defns.m:
Delete the type definitions moved to prog_item.m.
Modify the checking process slightly to allow it to check properly
the definitions we now put into .int, .int2 and .int3 files.
Add code to check inst and mode definitions as well as type definitions.
Since insts and modes have only one non-abstract kind of definition,
these codes are much simpler than the code for checking types.
compiler/comp_unit_interface.m:
Construct checked type, inst and mode definitions to put into
.int, .int2 and .int3 files. The .int2 and .int3 parts were
reasonably simple, but the .int part requires some detailed
case-by-case analysis.
compiler/convert_parse_tree.m:
Check the type, inst and mode definitions read in from .int/.int2/.int3
files when creating their parse trees. If those files were generated
by a compiler that has this diff, then this checking process should
not find any problems.
compiler/equiv_type.m:
Operate on checked type, inst and mode definitions instead of their
unchecked versions.
Delete an unneeded field from a structure.
compiler/error_util.m:
Add {qual,unqual}_{inst,mode}_ctor as format components, so that
any error messages about inst and mode definitions do not have to convert
inst_ctors and mode_ctors to symname/arity pairs.
compiler/item_util.m:
Add some utility predicates and functions needed by the changes above.
compiler/module_qual.collect_mq_info.m:
Since checked type, inst and mode definitions can contain info that is
derived from both the interface and implementation sections of a module,
add the capability to get only the *publicly* declared types, insts and
modes from their respective kinds of checked definitions.
compiler/module_qual.qualify_items.m:
Module qualify checked type, inst and mode definitions.
compiler/module_qual.qual_errors.m:
Treat references to inst_ctors and mode_ctors in qualification error
messages the same way as we treat type_ctors.
Also replace mq_ids that are intended to represent classes with class_ids,
to represent the intent better.
compiler/parse_tree_out.m:
Output the updated parse_trees of .int/.int2/.int3 files.
compiler/prog_data.m:
Add an XXX about a future change.
compiler/decide_type_repn.m:
compiler/get_dependencies.m:
compiler/grab_modules.m:
compiler/make_hlds_separate_items.m:
compiler/pred_table.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
Conform to the changes above.
library/maybe.m:
Add utility predicates needed by the code above.
NEWS:
Announce the new predicates in maybe.m.
tools/intdiffall:
A script that shows differences between the automatically generated
interface files between stage 1 and stage 2, which helped debug this diff.
|
||
|
|
af63e7cae2 |
Rewrite uses of some deprecated preds.
compiler/make.m:
compiler/mercury_compile_main.m:
As above.
compiler/error_util.m:
Delete deprecated predicates that have no calls anymore.
|
||
|
|
4d699229ff |
Provide more info in a warning.
compiler/add_type.m:
When a subtype lists data constructors in a different order than its
supertype, print a diff of the two orders, not just the list of
out-of-order constructors.
Give some predicates more expressive names.
compiler/style_checks.m:
compiler/error_util.m:
Move two predicates from style_checks to error_util.m
to allow them to be called from add_type.m.
tests/warnings/subtype_order.exp:
Expect the updated warning.
|
||
|
|
d02751a38b |
Add name_arity as a format_component.
compiler/error_util.m:
As above.
compiler/prog_data.m:
To make this possible, move the existing definitions of name_arity here.
compiler/hlds_defns.m:
compiler/pred_table.m:
Delete two the old copies of that definition.
|
||
|
|
b922d9b4d1 |
Use explicit streams in fact_table.m.
compiler/fact_table.m:
Use explicit streams.
Do not require callers to supply redundant information.
Replace several uses of booleans with values of bespoke types.
Move loop invariants that are not trivial access predicates out of loops.
Put constant input args (those passed to recursive calls unchanged)
before non-constant input args.
Put related args next to each other.
Replace uses of string.append and string.append_list with ++ and
string.format where the result is clearer code.
Document the reason why we do a task the hard way.
Update the generation of error messages.
Stop mixing underscores and CamelCase.
Improve variable names. In particular, stop the old practice
of giving variables 0 and 1 suffixes when computed from
the head and the tail of an input list respectively.
Replace /* */ comments with // comments in the generated C code
where possible.
Simplify some convoluted pieces of code.
Add XXXs for some potential problems and some potential improvements.
compiler/Mercury.options:
Do not specify --no-warn-implicit-stream-calls for fact_table.m.
compiler/arg_info.m:
Put constant input args before non-constant input args.
compiler/add_pragma.m:
compiler/bytecode_gen.m:
compiler/follow_vars.m:
Conform to the changes above.
compiler/error_util.m:
Improve indentation.
|
||
|
|
93c306916a |
Specify streams explicitly in more modules.
compiler/module_cmds.m:
Require all callers to specify output streams explicitly.
compiler/compile_target_code.m:
Require callers to specify output streams explicitly in most cases.
In the remaining cases, add "XXX STREAM" comments to request that
the explicit streams be passed later.
Add XXXs where preserving old behavior results in wrong-looking code.
Modify the signature of compile_java_files to encode the invariant that
the list of Java files given to it may not be empty.
compiler/error_util.m:
Provide a version of an error predicate that takes explicit streams.
compiler/make.build.m:
Mark predicates that help redirect implicit streams as predicates
that should not be used.
compiler/make.module_target.m:
compiler/make.program_target.m:
Add "XXX STREAM" comments to request that the explicit streams
be passed later.
compiler/module_qual.m:
Provide a means to construct the debug output stream.
compiler/module_qual.collect_mq_info.m:
Use the debug output stream where relevant.
compiler/analysis.m:
compiler/export.m:
compiler/recompilation.check.m:
compiler/source_file_map.m:
compiler/write_module_interface_files.m:
compiler/xml_documentation.m:
Conform to the changes above, mostly by passing explicit streams.
compiler/Mercury.options:
Stop specifying --no-warn-implicit-stream-calls for the above modules
(those that had it specified in the first place).
Delete a long-unneeded workaround.
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_middle_passes.m:
Specify progress and output streams explicitly when calling the modules
above (not in other places, just yet).
|
||
|
|
8355718b16 |
Allow pred pragmas to specify pred_or_func.
Pragmas that apply to a pred_info have traditionally specified that
pred_info by a symname/arity pair. However, this can be ambiguous
if there is both a predicate and a function with that symname/arity pair.
This diff therefore allows pragmas that previously took "symname/arity"
to also take "pred(symname/arity)" and "func(symname/arity").
If e.g. there is both a pred foo/2 and a func foo/2 accessible from
the current module, the old form applied to both, while the new forms
apply to just one.
Later, we could change the behavior of the old form to insist on a
unique match, but before we do, we should have a mechanism that allows
programmers to resolve the ambiguity. (They could rename either the
pred or the func, but it is less intrusive for the compiler not to
insist on that.) This is that mechanism.
In the process of implementing this change, I had to update lots of code
that dealt with arities, since one main difference between predicates
and functions is that for the latter, the user visible arity and
the internal compiler arity are different, in that the former does not
count the return value, and the latter does. The existing "arity" type
is an equivalence to int, and thus does not indicate which notion is meant.
I therefore added two notag types, user_arity and pred_form_arity,
for the two notions above respectively, and made a start on using them,
though for now, only in the code sections affected by the main change above.
compiler/prog_item.m:
Change the types that represent the specifications of predicates
(in the sense of pred_infos) and functions to allow the representation
of not just "symname/arity," but also "pred(symname/arity)" and
"func(symname/arity"). There is one exception: for the oisu (order
independent state update) pragma, require the presence of either
a pred() vs func() wrapper. This is not a breaking change, since oisu
pragmas are neither publicly documented or really implemented.
Pragmas that allow the representation of argument modes implicitly
specify pred vs func by taking the mode list either as
(m1, m2, ... mn) or as (m1, m2, ...) = mn. Encode this invariant
in the representation type. Make this type also include an arity
only in the absence of a mode list, to make unrepresentable
any inconsistent state in which the stated arity and the length
of the mode list disagree.
Give the new types used for these updated representations names
that state whether they specify a pred_info or a proc_info
(or in one case that we should later fix, that they can specify either).
Put the pred or func indication before the symname and arity
both in these new types, and in some old types. Do this both because
the pred or func indication comes before the name in Mercury declarations,
and to help the compiler find all the places where code using the old
forms had to be revisited and checked for any needed updates.
Provide utility operations on the new types involved in the
updated representations.
compiler/prog_data.m:
Add the user_arity and pred_form_arity types, as mentioned above.
Add a type that is mostly used in item representations, but is also
useful elsewhere.
compiler/parse_pragma.m:
compiler/parse_pragma_analysis.m:
compiler/parse_pragma_foreign.m:
compiler/parse_pragma_tabling.m:
compiler/parse_util.m:
Accept the pred() or func() wrappers mentioned above, and generate
the updated representations when parsing terms containing pragmas.
compiler/parse_tree_out_pragma.m:
Accept the updated representations of pragmas when printing them out.
compiler/add_pragma.m:
compiler/add_pragma_tabling.m:
compiler/add_pragma_type_spec.m:
Use the updated representations when adding pragmas to the HLDS.
compiler/error_util.m:
Provide mechanisms for use above when printing references to pred_infos
using user arities, to complement the existing mechanisms which use
arities that they treat as pred form arities. The latter is what
you want when generating error messages about pred_infos that
already included functions' return types in the argument list;
the former is what you want when generating error messages
about user input that has not yet been subject to that treatment,
such as a pragma that has just been read in. (The difference is
only in what form of arity these mechanisms take as *input*;
the output is always user arity, which after all is what users
are interested in.)
compiler/hlds_error_util.m:
Provide a user_arity equivalent to a piece of existing pred_form_arity
functionality, for use by the modules above.
Provide utility functions used when generating error messages.
compiler/fact_table.m:
Replace most uses of the "arity" type with the "user_arity" type.
Done mostly in the process of figuring out which kind of arity
the top predicates took as arguments.
Put argument lists into a sensible order.
compiler/prog_out.m:
compiler/prog_util.m:
Add utility functionality needed above.
compiler/add_mutable_aux_preds.m:
compiler/convert_parse_tree.m:
compiler/equiv_type.m:
compiler/get_dependencies.m:
compiler/intermod.m:
compiler/item_util.m:
compiler/make_hlds_passes.m:
compiler/module_qual.qualify_items.m:
compiler/recompilation.usage.m:
compiler/recompilation.version.m:
compiler/typecheck_errors.m:
compiler/unused_args.m:
Conform to the changes above.
compiler/hlds_pred.m:
Add an XXX.
compiler/notes/order_indep_state_update:
Fix typos.
tests/hard_coded/bad_direct_reuse.m:
tests/hard_coded/bad_indirect_reuse.m:
tests/hard_coded/bitmap_simple.m:
tests/hard_coded/constraint_order.m:
tests/hard_coded/equality_pred_which_requires_boxing.m:
tests/hard_coded/fact_table_test_1.m:
tests/hard_coded/float_consistency.m:
tests/hard_coded/foreign_enum_rtti.m:
tests/hard_coded/foreign_enum_switch.m:
tests/hard_coded/foreign_import_module_2.m:
tests/hard_coded/gh72.m:
tests/hard_coded/gh72a.m:
tests/hard_coded/heap_ref_mask_tag.m:
tests/hard_coded/intermod_multimode.m:
tests/hard_coded/mode_check_clauses.m:
tests/hard_coded/multimode_addr.m:
tests/hard_coded/type_spec_ho_term.m:
tests/hard_coded/user_defined_equality2.m:
Add pred() or func() wrappers to symname/arity pairs in pragmas,
to test whether the parser accepts them.
Fix deviations from our current coding standards.
tests/hard_coded/oisu_check_db.m:
tests/invalid/oisu_check_add_pragma_errors.{m,err_exp}:
tests/invalid/oisu_check_semantic_errors.m:
Add the pred() wrappers now required in oisu pragmas.
Expect the improved wording of an error message.
|
||
|
|
63dabcfcf8 |
Fix filling in partial terms that use direct_arg tags.
This fix uses the approach discussed on m-dev 2020 nov 16/17 for fixing github issue #72, whose core problem is a need for information flow back to a the caller from a callee when the callee fills in the argument of a function symbol whose representation is a direct_arg tag. In most cases when the callee fills in the value of an argument, the caller can see it because the argument is in a word on the heap, but when the function symbol uses a direct_arg tag, that is not the case. compiler/direct_arg_in_out.m: A new module that implements the transformation proposed on m-dev. It creates a fresh clone variable every time an argument of a direct_arg tag function symbol is (or may be) updated. This can happen several times if a type has more than one function symbol with a direct_arg tag. Since the affected variable can be bound to only one function symbol at the start, its argument can be filled in only once, but the compiler cannot know in advance what function symbol the variable contains, and therefore which of the possibly several fill-in sites (which fill in the arguments of different function symbols) executed in sequence will actually update the variable. The transformation ensures that once a variable is cloned, it is never referred to again. It also ensures that in a branched control structure (if-then-else, disjunction or switch), all branches will use the *same* variable to represent the latest version of each cloned variable at the end, so that following code has a consistent view regardless of through which branch execution has reached it. There are three situations that the transformation cannot and does not handle. 1. Situations in which the mode of an argument is either an inst variable, or an abstract inst. In either case, the pass cannot know whether it should apply its transformation to the argument. 2. Situations where a procedure that has such an argument is exported to C code as a function. In that case, the C signature of the function we would generate would be different from what the user would normally expect. We could modify the documentation of the export pragma, but I don't think there much point due to lack of demand. (The problem cannot arise when targeting any language other than C, because we use direct_arg tags only with the low level data representation, which we only use for C.) 3. Situations where a procedure that has such an argument is defined by foreign_proc. Again, dealing with the problem would require nontrivial changes to the documented interface between code in foreign_procs and the surrounding Mercury code, and I see no demand for code that could benefit from that. In these cases, this module generates error messages. compiler/transform_hlds.m: Include the new module in the transform_hlds package. Delete unnecessary module qualification on some existing inclusions. Put some existing inclusions into a more meaningful order. compiler/notes/compiler_design.html: Document the new pass. Fix some nearby prose. compiler/lambda.m: compiler/simplify_proc.m: Use a predicate exported by direct_arg_in_out.m to test, for each procedure, whether the procedure has any argument positions that are subject to the problem that direct_arg_in_out.m addresses. simplify_proc.m does this for all procedures it processes; lambda.m does this for all the procedures it creates from lambda expressions. Give a predicate in simplify_proc.m a better name. Sort a list of predicate names. compiler/hlds_module.m: Add a field to the module_info that simplify_proc.m and lambda.m can use to tell direct_arg_in_out.m what work (if any) it needs to do. compiler/mercury_compile_middle_passes.m: Invoke direct_arg_in_out.m if the new field in the HLDS indicates that it has some work to do. (In the vast majority of compiler invocations, it won't have any.) compiler/hlds_pred.m: The new code in direct_arg_in_out.m creates a clone of each procedure affected by the problem, before deleting the originals (to make sure that no references to the unfixed versions of now-fixed procedures remain.) Make it possible to create exact clones of both predicates and procedures by adding two pairs of predicates, {pred,proc}_prepare_to_clone and {pred,proc}_create. Add the direct_arg_in_out transformation as a possible source of transformed predicates. library/private_builtin.m: Add a new builtin operation, partial_inst_copy, that the new module generates calls to. configure.ac: Require the installed compiler to recognize partial_inst_copy as a no_type_info builtin. compiler/builtin_ops.m: Recognize the new builtin. (This was committed before the rest; the diff to private_builtin.m can be done only once the change to builtin_ops.m is part of the installed compiler.) compiler/options.m: Add a way to test whether the builtin_ops.m in the installed compiler recognizes the new builtin. compiler/dead_proc_elim.m: Do not delete the new primitive before direct_arg_in_out.m has had a chance to generate calls to it. Add an XXX. compiler/error_util.m: Recognize the new module as a source of error messages. compiler/pred_table.m: Add a pair of utility predicates to be used when looking up builtin predicates, for which the compiler writer knows that there should be exactly one match. These are used in direct_arg_in_out.m. compiler/simplify_goal_call.m: Replace some existing code with calls to the new predicates in pred_table.m. compiler/hlds_goal.m: Add modes to rename_vars_in_goal_expr that express the fact that when an atomic goal_expr has some variables renamed inside it, it does not suddenly become some *other* kind of goal_expr. New code in direct_arg_in_out.m relies on this. compiler/hlds_out_goal.m: When the HLDS we are dumping out is malformed because it contains calls to predicates that have been deleted, the compiler used to abort at such calls. (I ran into this while debugging direct_arg_in_out.m.) Fix this. When such calls are encountered, we now print out as much information we can about the call, and prefix the call with an unmistakable prefix to draw attention to the problem. compiler/inst_util.m: Fix a bug that prevented direct_arg_in_out.m from even being invoked on some test code for it. The bug was in code that we use to unify a headvar's initial inst with its final inst. When the initial inst was a non-ground bound_inst such as the ones used in tests/hard_coded/gh72.m, and the final inst was simply "ground", this code quite properly returned a bound_inst (which, unlike ground, can show the exact set of function symbols that the headvar could be bound to). The problem was that it reused the original bound_inst's test results, including the one that said the final inst is NOT ground, which of course is wrong for any inst unified with ground. Fix two instances of this bug. compiler/modes.m: Make some of the code I had to traverse to find the bug in inst_util.m easier to read and understand. Replace some uses of booleans with bespoke enum types. Change the argument lists of some predicates to put related arguments next to each other. Give some variables more descriptive names. compiler/layout_out.m: Conform to the change in hlds_pred.m. compiler/var_locn.m: Fix a code generation bug. When filling-in the value of the argument of a function symbol represented by a direct_arg tag, the code we generated for it worked only if the direct_arg tag used 0 as its ptag value. In the test cases we initially used for github issue 72, that was the case, but the new tests/hard_coded/gh72.m has direct_tag args that use other ptag values as well. Document the reason why the updated code works. compiler/term_constr_initial.m: Add the new primitive predicate added to private_builtin.m, partial_inst_copy, to a table of builtins that do not take type_infos, even though their signatures contain type variables. Fix a bunch of old bugs: most other such primitives were not listed either. mdbcomp/program_representation.m: Add partial_inst_copy to the master list of builtins that do not take type_infos even though their signatures contain type variables. (Done by an earlier commit.) Document the fact that any updates here require updates to term_constr_initial.m. library/multi_map.m: We have long had multi_map.add and multi_map.set as synonyms, but we only had multi_map.reverse_set. Add multi_map.reverse_add as a synonym for it. Define the "set" versions in terms of the "add" versions, instead of vice versa. NEWS: Document the new predicates in multi_map.m. tests/hard_coded/gh72a.m: Fix typo. tests/hard_coded/gh72.{m,exp}: A new, much more comprehensive test case than gh72a.m. This one tries to tickle github issue 72 in as many forms of code as I can think of. tests/invalid/gh72_errors.{m,err_exp}: A test case for testing the generation of error messages for two out of the three kinds of situations that direct_arg_in_out.m cannot handle. (Proposals for how to test the third category welcome.) tests/hard_coded/Mmakefile: tests/invalid/Mmakefile: Enable the two new test cases, as well as two old ones, gh72[ab].m, that previously we didn't pass. tests/invalid/Mercury.option: Do not compile gh72_error.m with --errorcheck-only, since its errors are reported by a pass that --errorcheck-only does not invoke. |
||
|
|
fda04a22bd |
Teach error util about class_ids.
compiler/error_util.m:
Let a format component represent class ids directly.
compiler/check_typeclass.m:
Use the new capability in error_util.m to simplify code by
avoiding explicit conversions from class_ids to sym_name/arity pairs.
|
||
|
|
7c446cd254 | Document a predicate. | ||
|
|
c5ec27235d | Make a utlity predicate generally available. | ||
|
|
08147bdfe8 | Add a new phase, to be used soon. | ||
|
|
2e951421dd |
Replace some bools with bespoke types.
compiler/globals.m:
compiler/write_module_interface_files.m:
As above.
compiler/error_util.m:
compiler/handle_options.m:
compiler/mercury_compile_main.m:
compiler/read_modules.m:
Conform to the changes in globals.m.
In mercury_compile_main.m, add an XXX.
|
||
|
|
204b7ae6dd |
Compile the compiler with --warn-dead-preds.
compiler/COMP_FLAGS.in:
Specify --warn-dead-preds for all modules by default.
compiler/Mercury.options:
Stop specifying --warn-dead-preds for modules individually.
compiler/mlds_to_c_func.m:
compiler/mlds_to_c_type.m:
compiler/parse_tree_out_type_repn.m:
Delete some unused predicates.
compiler/equiv_type_hlds.m:
Shut up a warning about an unused predicate that may be needed later.
compiler/det_analysis.m:
Use a bespoke format component.
compiler/error_util.m:
Fix some comments.
compiler/process_util.m:
Don't use mode-specific clauses unnecessarily.
compiler/timestamp.m:
Give a predicate a more descriptive name.
|
||
|
|
dbd19430ef |
Use full error_specs instead of pieces.
compiler/compile_target_code.m:
compiler/fact_table.m:
compiler/mercury_compile_mlds_back_end.m:
compiler/module_cmds.m:
compiler/pred_table.m:
Replace calls to write_error_pieces* with code that constructs
full error_specs and then writes them out.
compiler/error_util.m:
Add a new phase, phase_fact_table_check, for the new code in fact_table.m.
|
||
|
|
86f8696f32 | Put globals before error_specs. | ||
|
|
4f32c50822 |
Let clauses with unknown warnings be processed.
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. |
||
|
|
1b56de1dc2 |
Prevent error exit without error messages.
Code I introduced on 2020 march 13 to filter out error_specs if the option
--print-errors-warnings-when-generating-interface is not set could
delete error messages *after* the exit status of the compiler has been set
to a nonzero value. This would mean that an invocation of mmc with
--make-interface would fail to create the requested interface file,
which would mean that the mmake invocation that invoked mmc would stop,
but would give absolutely no indication of *why* it stopped.
This diff fixes that bug. The diff has two main parts.
compiler/error_util.m:
The first part is: make filter_interface_generation_specs test
the exit status, and refuse to filter out any error messages
if the exit status has already been set to indicate failure.
compiler/write_module_interface_files.m:
In the predicates that generate and write out the contents of the
module qualified interface files, go back to their previous structure.
(The errors that we could omit to issue were errors discovered during
module qualification).
This diff is not the ideal fix, but the ideal fix requires changes
to how we test errors generated while making interface files, and thus
is left for future work.
compiler/mercury_compile_main.m:
Conform to the change in error_util.m.
compiler/hlds_error_util.m:
Update a comment after the renaming of a predicate.
|
||
|
|
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.
|
||
|
|
5c52cf0cde |
Standardize on "sym_name_arity" ...
... replacing "sym_name_AND_arity". |
||
|
|
9789375cc5 |
Make pre-HLDS passes use file-kind-specific parse trees.
Replacing item blocks file-kind-specific kinds of section markers with
file-kind-specific parse trees has several benefits.
- It allows us to encode the structural invariants of each kind of file
we read in within the type of its representation. This makes the detection
of any accidental violations of those invariants trivial.
- Since each file-kind-specific parse tree has separate lists for separate
kinds of items, code that wants to operate on one or a few kinds of items
can just operate on those kinds of items, without having to traverse
item blocks containing many other kinds of items as well. The most
important consequence of this is not the improved efficiency, though
that is nice, but the increased clarity of the code.
- The new design is much more flexible. For example, it should be possible
to record that e.g. an interface file we read in as a indirect dependency
(i.e. a file we read not because its module was imported by the module
we are compiling, but because its module was imported by *another* imported
module) should be used *only* for the purpose it was read in for. This should
avoid situations where deleting an import of A from a module, because it
is not needed anymore, leads the compiler to generate an error message
about a missing import of module B. This can happen if (a) module B
always *should* have been imported, since it is used, but (b) module A's
import of module B lead to module B's interface being available *without*
an import of B.
Specifically, this flexibility should enable us to establish each module's
.int file as the single source of truth about how values of each type
defined in that module should be represented. When compiling each source
file, this approach requires the compiler to read in that module's .int file
but using only the type_repn items from that .int file, and nothing else.
- By recording a single parse tree for each file we have read, instead of
a varying number of item blocks, it should be significantly easier to
derive the contents of .d files directly from the records of those
parse trees, *without* having to maintain a separate set of fields
in the module_and_imports structure for that purpose. We could also
trivially avoid any possibility of inconsistencies between these two
different sources of truth. (We currently fill in the fields used to
drive the generation of .d files using two different pieces of code,
one used for --generate-dependencies and one used for all other invocations,
and these two *definitely* generate inconsistent results, as the significant
differences in .d files between (a) just after an invocation of
--generate-dependencies and (b) just after any other compiler invocation
can witness.)
This change is big and therefore hard to review. Therefore in many files,
this change adds "XXX CLEANUP" comments to draw attention to places that
have issues that should be fixed, but whose fixes should come later, in
separate diffs.
compiler/module_imports.m:
The compiler uses the module_and_imports structure defined here
to go from a raw compilation unit (essentially a module to be compiled)
to an augmented compilation unit (a raw compilation unit together
with all the interface and optimization files its compilation needs).
We used to store the contents of both the source file and of
the interface and optimization files in the module_and_imports structure
as item blocks. This diff replaces all those item blocks with
file-kind-specific parse trees, for the reasons mentioned above.
Separate out the .int0 files of ancestors modules from the .intN
files for N>0 of directly imported modules. (Their item blocks
used to be stored in the same list.)
Maintain a database of the source, interface and optimization files
we have read in so far. We use it to avoid reading in interface files
if we have already read in a file for the same module that contains
strictly more information (either an interface file with a smaller
number as a suffix, or the source file itself).
Shorten some field names.
compiler/prog_item.m:
Define data structures for storing information about include_module,
import_module and use_module declarations, both in a form that allows
the representation of possibly erroneous code in actual source files,
and in checked-and-cleaned-up form which is guaranteed to be free
of the relevant kinds of errors. Add a block comment at the start
of the module about the need for this distinction.
Define parse_tree_module_src, a data structure for representing
the source code of a single module. This is different from the existing
parse_tree_src type, which represents the contents of a single source file
but which may contain *more* than one module, and also different from
a raw_compilation_unit, which is based on item blocks and is thus
unable to express to invariants such as "no clauses in the interface".
Modify the existing parse_tree_intN types to express the distinction
mentioned just above, and to unify them "culturally", i.e. if they
store the same information, make them store it using the same types.
Fix a mistake by allowing promises to appear in .opt files.
I originally ruled them out because the code that generates .opt files
does not have any code to write out promises, but some of the predicates
whose clauses it writes out have goal_type_promise, which means that
they originated as promises, and get written out as promises.
Split the existing pragma item kind into three item kinds, which have
different invariants applying to them.
- The decl (short for declarative) pragmas give the compiler some
information, such as that a predicate is obsolete or that we
want to type specialize some predicate or function, that is in effect
part of the module's interface. Decl pragmas may appear in module
interfaces, and the compiler may put them into interface files;
neither statement is true of the other two kinds of pragmas.
- The impl (short for implementation) pragmas are named so
precisely because they may appear only in implementation sections.
They give the compiler information that is private to that module.
Examples include foreign_decls, foreign_codes, foreign_procs,
and promises of clause equivalence, and requests for inlining,
tabling etc. These will never be put into interface files,
though some of them can affect the compilation of other modules
by being included in .opt files.
- The gen (short for generated) pragmas can never (legally) appear
in source files at all. They record the results of compiler
analyses e.g. about which arguments of a predicate are unused,
or what exceptions a function can throw, and accordingly they
should only ever occur in compiler-generated interface files.
Use the new type differences between the three kinds of pragmas
to encode the above invariants about which kinds of pragmas can appear
where into the various kinds of parse trees.
Make the augmented compilation unit, which is computed from
the final module_and_imports structure, likewise switch from
storing item blocks to storing the whole parse trees of the
files that went into its construction. With each such parse tree,
record *why* we read it, since this controls what permissions
the source module being compiled has for access to the entities
in the parse tree.
Simplify the contains_foreign_code type, since one of three
function symbols was equivalent to one possible use of another
function symbol.
Provide a way to record which method of which class a compiler-generated
predicate is for. (See hlds_pred.m below.)
Move the code of almost all utility operations to item_util.m
(which is imported by many fewer modules than prog_item.m),
keeping just the most "popular" ones.
compiler/item_util.m:
Move most of the previously-existing utility operations here from
prog_item.m, most in a pretty heavily modified form.
Add a whole bunch of other utility operations that are needed
in more than one other module.
compiler/convert_parse_tree.m:
Provide predicates to convert from raw compilation units to
parse_tree_module_srcs, and vice versa (though the reverse
shouldn't be needed much longer).
Update the conversion operations between the general parse_tree_int
and the specific parse_tree_intN forms for the changes in prog_item.m
mentioned above. In doing so, use a consistent approach, based on
new operations in item_util.m, to detect errors such as duplicate
include_module and import/use_module declarations in all kinds
of parse trees.
Enforce the invariants that the types of parse trees of various kinds
can now express in types, generating error messages for their violations.
Delete some utility operations that have been moved to item_util.m
because now they are also needed by other modules.
compiler/grab_modules.m:
Delete code that did tests on raw compilation units that are now done
when that raw compilation unit is converted to a parse_tree_module_src.
Use the results of the checks done during that conversion to decide
which modules are imported/used and in which module section.
Record a single reason for why we reading in each interface and
optimization file. The code of make_hlds_separate_items.m will use
this reason to set up the appropriate permissions for each item
in those files.
Use separate code for handling different kinds of interface and
optimization files. Using generic traversal code was acceptable economy
when we used the same data structure for every kind of interface file,
but now that we *can* express different invariants for different kinds
of interface and optimization file, we want to execute not just different
code for each kind of file, but the data structures we want to work on
are also of different types. Using file-kind-specific code is a bit
longer, but it is significantly simpler and more robust, and it is
*much* easier to read and understand.
Delete the code that separates the parts of the implementation section
that are exported to submodules, and the part that isn't, since that task
is now done in make_hlds_separate_items.m.
Pass a database of the files we have read through the relevant predicates.
Give some predicates more meaningful names.
compiler/notes/interface_files.html:
Note a problem with the current operation of grab_modules.
compiler/get_dependencies.m:
Add operations to gather implicit references to builtin modules
(which have to be made available even without an explicit import_module
or use_module declaration) in all kinds of parse trees. These have
more code overall, but will be at runtime, since we need only look at
the item kinds that may *have* such implicit references.
Add a mechanism to record the result of these gathering operations
in import_and_or_use_maps.
Give some types, function symbols, predicates and variables
more meaningful names.
compiler/make_hlds_separate_items.m:
When we stored the contents of the source module and the
interface and optimization files we read in to augment it
in the module_and_imports structure as a bunch of item blocks,
the job of this module was to separate out the different kinds of items
in the item blocks, returning a single list of each kind of item,
with each such item being packaged up with its status (which encodes
a set of permissions saying what the source module is allowed
to do with it).
Now that the module_and_imports structure stores this info in
file-kind-specific parse trees, all of which have separate lists
for each kind of item and none of which contain item blocks,
the job of this module has changed. Now its job is to convert
the reason why each file was read in into the (one or more) statuses
that apply to the different kinds of items stored in it, wrap up
each item with its status, and return the resulting overall list
of status/item pairs for each kind of item.
compiler/read_modules.m:
Add predicates that, when reading an interface file, return its contents
in the tightest possible file-kind-specific parse tree.
Refine the database of files we have read to allow us to store
more file-kind-specific parse trees.
Don't require that files in the database have associated timestamps,
since in some cases, we read files we can put into the database
*without* getting their timestamps.
Allow the database to record that an attempt to read a file failed.
compiler/split_parse_tree_src.m:
Rearchitect how this module separates out nested submodules from within
the main module in a file.
Another of the jobs of this module is to generate error messages for
when module A includes module B twice, whether via nesting or via
include_module declarations, with one special exception for the case
where A's interface contains nested submodule A.B's interface,
and A's implementation contains nested submodule A.B's implementation.
The problem ironically was that while it reported duplicate include_module
declarations as errors, split_parse_tree_src.m also *generated*
duplicate include_module declarations. Since it replaced each nested
submodule occurrence with an include_module declaration, in the scenario
above, it generated two include_module declarations for A.B. Even worse,
the interface incarnation of submodule A.B could contain
(the interface of) its own nested submodule A.B.C, while its
implementation incarnation could contain (the implementation section of)
A.B.C. Each occurrence of A.B.C would be its only occurrence in the
including part of its parent A.B, which means local tests for duplicates
do not work. (I found this out the hard way.)
The solution we now adopt adds include_module declarations to the
parents of any submodule only once the parse tree of the entire
file has been processed, since only then do we know all the
includer/included relationships among nested modules. Until then,
we just record such relationships in a database as we discover them,
reporting duplicates when needed (e.g. when A includes B twice
*in the same section*), but not reporting duplicates when not needed
(e.g. when A.B includes A.B.C in *different* sections).
compiler/prog_data.m:
Add a new type, pf_sym_name_and_arity, that exactly specifies
a predicate or function. It is a clone of the existing simple_call_id
type, but its name does NOT imply that the predicate or function
is being called.
Add XXXs that call for some other improvements in type names.
compiler/prog_data_foreign.m:
Give a type, and the operations on that type, a more specific name.
compiler/error_util.m:
Add an id field to all error_specs, which by convention should be
filled in with $pred. Print out the value in this field if the compiler
is invoked with the developer-only option --print-error-spec-id.
This allows a person debugging the compiler find out where in the code
an undesired error message is coming from significantly easier
than was previously possible.
Most of the modules that have changes only "to conform to the changes
above" will be for this change. In many cases, the updated code
will also simplify the creation of the affected error_specs.
Fix a bug that looked for a phase in only one kind of error_spec.
Add some utility operations needed by other parts of this change.
Delete a previously internal function that has been moved to
mdbcomp/prim_data.m to make it accessible in other modules as well.
compiler/Mercury.options:
Ask the compiler to warn about dead predicates in every module
touched by this change (at least in one its earlier versions).
compiler/add_foreign_enum.m:
Replace a check for an inappropriately placed foreign_enum declaration
with a sanity check, since with this diff, the error should be caught
earlier.
compiler/add_mutable_aux_preds.m:
Delete a check for an inappropriately placed mutable declaration,
since with this diff, the error should be caught earlier.
compiler/add_pragma.m:
Instead of adding pass2 and pass3 pragmas, add decl and impl and
generated pragmas.
Delete the tests for generated pragma occurring anywhere except
.opt files, since those tests are now done earlier.
Shorten some too-long predicate names.
compiler/comp_unit_interface.m:
Operate on as specific kinds of parse trees as the interface of this
module will allow. (We could operate on more specific parse trees
if we changed the interface, but that is future work).
Use the same predicates for handling duplicate include_module,
import_module and use_module declarations as everywhere else.
Delete the code of an experiment that shouldn't be needed anymore.
compiler/equiv_type.m:
Replace code that operated on item blocks with code that operates
on various kinds of parse trees.
Move a giant block of comments to the front, where it belongs.
compiler/hlds_module.m:
Add a field to the module_info that lets us avoid generating
misleading error messages above missing definitions of predicates
or functions when those definitions were present but were not
added to the HLDS because they had errors.
Give a field and its access predicates a more specific name.
Mark a spot where an existing type cannot express everything
it is supposed to.
compiler/hlds_pred.m:
For predicates which the compiler creates to represent a class method
(the virtual function, in OOP terms), record not just this fact,
but the id of the class and of the method. Using this extra info
in progress messages (with mmc -V) prevents the compiler from printing e.g.
% Checking typeclass constraints on class method
% Checking typeclass constraints on class method
% Checking typeclass constraints on class method
when checking three such predicates.
compiler/make.m:
Provide a slot in the make_info structure to allow the database
of the files we have read in to be passed around.
compiler/make_hlds_error.m:
Delete predicates that are needed in just one other module,
and have therefore been moved there.
compiler/make_hlds_passes.m:
Add decl, impl and generated pragma separately, instead of adding
pass2 and pass3 pragmas separately.
Do not generate error messages for clauses, initialises or finalises
in module interfaces, since with this diff, such errors should be
caught earlier.
compiler/mercury_compile_main.m:
compiler/recompilation.check.m:
Explicitly pass around the expanded database of parse trees
of files that have been read in.
compiler/module_qual.collect_mq_info.m:
compiler/module_qual.m:
compiler/module_qual.qualify_items.m:
Collect module qualification information, and do module qualification
respectively on parse trees of various kinds, not item blocks.
Take information about what the module may do with the contents
of each interface or optimization file from the record of why
we read that file, not from the section markers in item blocks.
Break up some too-large predicates by carving smaller ones out of them.
compiler/options.m:
Add an option to control whether errors and/or warnings detecting
when deciding what should go into a .intN file be printed,
thus (potentially) preventing the creation of that file.
Add commented-out documentation for a previously totally undocumented
option.
doc/user_guide.texi:
Document the new option.
NEWS:
Announce the new option.
Mention that we now generate warnings for unused import_module and
use_module declarations in the interface even if the module has
submodules.
compiler/write_module_interface_files.m:
Let the new option control whether we filter out any messages generated
when deciding what should go into a .intN file.
compiler/parse_item.m:
Delete actually_read_module_opt, since it is no longer needed;
its callers now call actually_read_module_{plain,trans}_opt instead.
Delete unneeded arguments from some predicates.
compiler/parse_module.m:
Delete some long unused predicates.
compiler/parse_pragma.m:
When parsing pragmas, wrap them up in the new decl, impl or generated
pragma kinds.
compiler/parse_tree_out.m:
Add predicates to write out each of the file-kind-specific parse trees.
compiler/parse_tree_out_pragma.m:
Add predicates to write out decl, impl and generated pragmas.
compiler/polymorphism.m:
Add a conditionally-enabled progress message, which can be useful
in tracking down problems.
compiler/prog_item_stats.m:
Conform NOT to the changes above beyond what is needed to let this module
compile. Let that work be done the next time the functionality of
this module is needed, by which time the affected data structures
maybe have changed further.
compiler/typecheck.m:
Fix a performance problem. With intermodule optimization, we read in
.opt files, some of which (e.g. list.opt and int.opt) contain promises.
These promises are read in as predicates with goal_type_promise,
but they do not have declarations of the types of their arguments
(since promises do not have declarations as such). Those argument types
therefore have to be inferred. That inference replaces the original
"I don't know" argument types with their actual types.
The performance problem is that when we change the recorded argument types
of a predicate, we require another loop over all the predicates in the
module, so that any calls to this predicate can be checked against
the updated types. This is as it should be for callable predicates,
but promises are not callable. So if all the *only* predicates whose
recorded argument types change during the first iteration to fixpoint
are promises, then a second iteration is not needed, yet we used to do it.
The fix is to replace the "Have the recorded types of this predicate
changed?" boolean flag with a bespoke enum that says "Did the checking
of this predicate discover a need for another iteration", and not
setting it when processing predicates whose type is goal_type_promise.
compiler/typecheck_errors.m:
Do not generate an error message for a predicate missing its clauses
is the clauses existed but were not added to the HLDS because they were
in the interface section.
When reporting on ambiguities (when a call can match more than one
predicate or function), sort the possible matches before reporting
them.
compiler/accumulator.m:
compiler/add_class.m:
compiler/add_clause.m:
compiler/add_foreign_proc.m:
compiler/add_mode.m:
compiler/add_pragma_tabling.m:
compiler/add_pragma_type_spec.m:
compiler/add_pred.m:
compiler/add_type.m:
compiler/canonicalize_interface.m:
compiler/check_for_missing_type_defns.m:
compiler/check_parse_tree_type_defns.m:
compiler/check_promise.m:
compiler/check_raw_comp_unit.m:
compiler/check_typeclass.m:
compiler/common.m:
compiler/compile_target_code.m:
compiler/compiler_util.m:
compiler/dead_proc_elim.m:
compiler/deps_map.m:
compiler/det_analysis.m:
compiler/det_report.m:
compiler/du_type_layout.m:
compiler/field_access.m:
compiler/find_module.m:
compiler/float_regs.m:
compiler/format_call.m:
compiler/goal_expr_to_goal.m:
compiler/handle_options.m:
compiler/hlds_out_module.m:
compiler/hlds_out_pred.m:
compiler/hlds_out_util.m:
compiler/inst_check.m:
compiler/intermod.m:
compiler/introduce_parallelism.m:
compiler/layout_out.m:
compiler/make.dependencies.m:
compiler/make.module_dep_file.m:
compiler/make_hlds_warn.m:
compiler/mark_tail_calls.m:
compiler/mercury_compile_llds_back_end.m:
compiler/ml_top_gen.m:
compiler/mmakefiles.m:
compiler/mode_errors.m:
compiler/mode_robdd.equiv_vars.m:
compiler/modes.m:
compiler/module_qual.qual_errors.m:
compiler/oisu_check.m:
compiler/old_type_constraints.m:
compiler/options_file.m:
compiler/parse_class.m:
compiler/parse_dcg_goal.m:
compiler/parse_goal.m:
compiler/parse_inst_mode_defn.m:
compiler/parse_inst_mode_name.m:
compiler/parse_mutable.m:
compiler/parse_sym_name.m:
compiler/parse_type_defn.m:
compiler/parse_type_name.m:
compiler/parse_type_repn.m:
compiler/parse_types.m:
compiler/parse_util.m:
compiler/parse_vars.m:
compiler/post_term_analysis.m:
compiler/post_typecheck.m:
compiler/prog_event.m:
compiler/prog_mode.m:
compiler/purity.m:
compiler/qual_info.m:
compiler/recompilation.version.m:
compiler/resolve_unify_functor.m:
compiler/simplify_goal.m:
compiler/simplify_goal_call.m:
compiler/simplify_goal_disj.m:
compiler/simplify_goal_ite.m:
compiler/simplify_proc.m:
compiler/state_var.m:
compiler/stratify.m:
compiler/style_checks.m:
compiler/superhomogeneous.m:
compiler/table_gen.m:
compiler/term_constr_errors.m:
compiler/term_errors.m:
compiler/termination.m:
compiler/trace_params.m:
compiler/unused_args.m:
compiler/unused_imports.m:
compiler/write_deps_file.m:
compiler/xml_documentation.m:
Conform to the changes above.
mdbcomp/prim_data.m:
Move a utility function on pred_or_funcs here from a compiler module,
to make it available to other compiler modules as well.
scripts/compare_s1s2_lib:
A new script that helped debug this diff, and may help debug
similar diffs the future. It can compare (a) .int* files, (b) .*opt
files, (c) .mh/.mih files or (d) .c files between the stage 1 and
stage 2 library directories. The reason for the restriction
to the library directory is that any problems affecting the
generation of any of these kinds of files are likely to manifest
themselves in the library directory, and if they do, the bootcheck
won't go on to compile any of the other stage 2 directories.
tests/debugger/breakpoints.a.m:
tests/debugger/breakpoints.b.m:
Move import_module declarations to the implementation section
when they are not used in the interface. Until now, the compiler
has ignored this, but this diff causes the compiler to generate
a warning for such misplaced import_module declarations even modules
that have submodules. The testing of such warnings is not the point
of the breakpoints test.
tests/invalid/Mercury.options:
Since the missing_interface_import test case tests error messages
generated during an invocation of mmc --make-interface, add the
new option that *allows* that invocation to generate error messages.
tests/invalid/ambiguous_overloading_error.err_exp:
tests/invalid/max_error_line_width.err_exp:
tests/warnings/ambiguous_overloading.exp:
Expect the updated error messages for ambiguity, in which
the possible matches are sorted.
tests/invalid/bad_finalise_decl.m:
tests/invalid/bad_initialise_decl.m:
Fix programming style.
tests/invalid/bad_item_in_interface.err_exp:
Expect an error message for a foreign_export_enum item in the interface,
where it should not be.
tests/invalid/errors.err_exp:
Expect the expanded wording of a warning message.
tests/invalid/foreign_enum_invalid.err_exp:
Expect a different wording for an error message. It is more "standard"
but slightly less informative.
tests/invalid_submodules/children2.m:
Move a badly placed import_module declaration, to avoid having
the message the compiler now generates for it from affecting the test.
tests/submodules/parent2.m:
Move a badly placed import_module declaration, to avoid having
the message the compiler now generates for it from affecting the test.
Update programming style.
|
||
|
|
d9ebe5647f |
Make it easier to construct conditional error messages.
compiler/error_util.m:
Add conditional_spec, a kind of error_spec that is conditional
on a specified option having a specified value.
Modify an exported utility predicate to accommodate this new construct,
and specialize it to its current uses (which are also its expected
future uses).
compiler/mode_errors.m:
compiler/recompilation.check.m:
Conform to the changes above.
|
||
|
|
5028b44b59 |
Use standard library functions to (un)capitalize words.
compiler/det_report.m:
compiler/error_util.m:
Use standard library functions to (un)capitalize words.
Delete redundant functions.
|
||
|
|
ee6fde3eb6 | Delete an unneeded type synonym. | ||
|
|
fc347fb6a1 |
Stop generating interface files only in the presence of errors.
compiler/write_module_interface_files.m:
If the code that computes the contents of an interface file also
generates messages to the user, don't take the mere existence of
these messages as grounds for not writing out the interface file;
instead, require them to report errors, or (if --halt-at-warn is enabled)
warnings.
compiler/error_util.m:
Provide a predicate for checking the above condition.
compiler/check_raw_comp_unit.m:
Fix, in two different ways, the warning that indicated the need for
the change to write_module_interface_files. First, if the module
exports nothing, then generate a warning only if warn_nothing_exported
is set, instead of always generating a warning that is conditional
on warn_nothing_exported being set. The latter doesn't just tickle
the problem mentioned above, it also uses more complex code. Second,
fix the wording of the warning.
tests/invalid/bigtest.err_exp:
tests/invalid/duplicate_modes.err_exp:
tests/invalid/empty_interface.err_exp:
tests/invalid/errors.err_exp:
tests/invalid/errors1.err_exp:
tests/invalid/errors2.err_exp:
tests/invalid/funcs_as_preds.err_exp:
tests/invalid/inst_list_dup.err_exp:
tests/invalid/no_exports.err_exp:
tests/invalid/occurs.err_exp:
tests/invalid/prog_io_erroneous.err_exp:
tests/invalid/type_inf_loop.err_exp:
tests/invalid/typeclass_missing_det_3.err_exp:
tests/invalid/typeclass_no_param.err_exp:
tests/invalid/typeclass_test_11.err_exp:
tests/invalid/types.err_exp:
tests/invalid/undef_inst.err_exp:
tests/invalid/undef_mode.err_exp:
tests/invalid/undef_type.err_exp:
tests/invalid/unicode1.err_exp:
tests/invalid/unicode2.err_exp:
tests/invalid/vars_in_wrong_places.err_exp:
Expect the improved wording of the warning.
|
||
|
|
3d37c6a442 |
Report wrongly qualified type names in foreign enums when parsing.
This fixes Mantis bug #486. compiler/parse_pragma.m: Read in the name of the type in a foreign enum in whatever qualified form it is in the source code, and then try to implicitly qualify it, generating a specific error message if that attempt is unsuccessful. compiler/parse_sym_name.m: To make the above possible, expose the code that does the implicit qualification. Do so not just in the form now needed by parse_pragma.m, but in the other forms used by other predicates in parse_sym_name.m as well, since they probably will be needed sooner or later. (The lack of such separated-out capability is what led to the code that caused bug 486 in the first place.) Avoid an unneeded asymmetry by providing mechanisms to parse implicitly qualified sym_names without arguments, as well as with arguments. compiler/parse_util.m: Give several of the predicates involved in the above more expressive names. compiler/parse_inst_mode_defn.m: compiler/parse_type_defn.m: compiler/parse_type_repn.m: compiler/recompilation.check.m: Conform to the changes above. compiler/error_util.m: Fix a bug that silently deleted the newly-added simplest_specs, which this diff uses for the first time. Add determinism requirements to avoid similar problems in the future. compiler/add_foreign_enum.m: Note that the old code that diagnosed attempts to define foreign_enums for types in other modules should not be needed anymore. tests/invalid/foreign_enum_import.err_exp: Expect the error message now generated by parse_pragma.m, which is more specific than the one generated by add_foreign_enum.m until now. tests/valid/bug486.m: tests/valid/bug486.window.m: A regression test for the bug. tests/valid/Mmakefile: Enable the new test. |
||
|
|
19ef98b66f |
Check the type definitions in a module for consistency ...
... when generating interface files.
compiler/check_parse_tree_type_defns.m:
A new module for doing the checking.
compiler/parse_tree.m:
Add the new module.
compiler/comp_unit_interface.m:
When computing what should go into a .intN file, use the new module
to check for inconsistencies in the source code of the module.
Making the above possible requires retaining some information
(such as contexts in foreign enum definitions, and the presence
of definitions, as opposed to declarations, for some types)
for longer than was needed until now.
Give some predicates more descriptive names.
Move the record_foreign_enum_spec predicate near where it is used.
compiler/write_module_interface_files.m:
If comp_unit_interface.m reports any errors when generating the
would-be contents of an interface file, do NOT create that
interface file.
The errors comp_unit_interface.m and check_parse_tree_type_defns.m
now generate are the kinds of inconsistencies whose resolution requires
everything depending on this module to be recompiled anyway,
so stopping the compilation process *without* producing
the would-be-erroneous interface file should be a net win
almost all the time.
compiler/prog_item.m:
Factor out some commonalities in data structures.
When converting the generic parse_tree_int we get from reading
in a .intN file to the parse tree type specific to that N,
check the definitions we read in for consistency.
As in comp_unit_interface, making the above possible requires
retaining some information for longer than was needed until now.
Never output two or more declarations of the same type_ctor
in the same section of an interface file, since the code
*reading* interface files now reports such redundancies
(but see the change to options.m).
compiler/options.m:
Disable the printing of error messages for problems found in
interface files, since the new code in check_parse_tree_type_defns.m
now finds problems in interface files generated by currently
installed compilers. Specifically, many contain duplicate
declarations for Mercury types. One declaration is written
by the programmer, the other is the type's actual definition
turned into the redundant declaration by the compiler.
compiler/parse_pragma.m:
When parsing foreign enum pragmas, implicitly qualify the
name of the type constructor they are for with the current module name.
This is semantically sound, since foreign_enum pragmas *must* be
for a type constructor defined in the same module. It is desirable
because type_ctors in type definitions are module qualified.
The code of check_parse_tree_type_defns.m needs to process
the type definitions and foreign enums for a type_ctor at the
same time, and doing so would be more needlessly complicated
if the type ctor keys in the "type_ctor to type definitions"
and "type_ctor to foreign enums" maps were incompatible due to
the difference in qualification.
The type_ctor in a foreign enum definition may still be manually
module qualified by programmers; it just happens that any qualification
other than the default is a semantic error.
compiler/module_qual.qual_errors.m:
When printing error messages about undefined type_ctors in
foreign enum definitions, do not print this implicitly
added qualification, since it adds only clutter.
compiler/error_util.m:
Provide a mechanism for printing type_ctors directly,
i.e. without converting them to a sym_name/arity pair.
Put a qual_ prefix in front of top_ctor_of_type, since it
always prints module qualification. (This is to remind people
who may use this component about that qualification.)
Factor out some common code.
compiler/det_analysis.m:
Conform to the change in error_util.m.
compiler/parse_module.m:
Fix too-long lines.
compiler/Mercury.options:
Require some of the modules above to have no dead predicates.
library/erlang_rtti_implementation.m:
library/io.m:
Delete declarations of types that are unneeded because the types
also have definitions.
tests/typeclasses/unqualified_method2.m:
Move an import out of the interface, since we now print the warning
generated for its improper location.
|
||
|
|
b21d4520df |
Make writing simple error messages easier.
compiler/error_util.m:
Introduce simplest_msg(Context, Pieces) as shorthand
for the common code pattern simple_msg(Context, [always(Pieces)]).
Introduce simplest_spec(Severity, Phase, Context, Pieces) as shorthand
for the common code pattern error_spec(Severity, Phase,
[simple_msg(Context, [always(Pieces)])]).
compiler/mode_errors.m:
compiler/recompilation.check.m:
Update code handling error specs to handle the new alternatives.
compiler/options.m:
Provide a mechanism to check whether a compiler contains this diff.
|
||
|
|
2c68193c08 |
Mark some redundant library predicates obsolete.
library/set.m:
library/set_bbbtree.m:
library/set_ctree234.m:
library/set_ordlist.m:
library/set_tree234.m:
library/set_unordlist.m:
Mark empty/1 and non_empty/1 as obsolete with is_empty and is_non_empty
as suggested replacements, and mark set/1 as obsolete with list_to_set/1
as suggested replacement.
NEWS:
Mention the above changes.
configure.ac:
Require the installed compiler to handle suggested replacements
in obsolete pragmas.
compiler/analysis.m:
Avoid calling the newly obsolete predicates.
Remove a workaround that probably hasn't been needed in a long time.
compiler/error_util.m:
compiler/hlds_args.m:
compiler/intermod.m:
compiler/make.dependencies.m:
compiler/make.module_dep_file.m:
compiler/mercury_compile_main.m:
compiler/module_cmds.m:
compiler/old_type_constraints.m:
compiler/options.m:
compiler/ordering_mode_constraints.m:
compiler/par_conj_gen.m:
compiler/parse_pragma.m:
compiler/prog_ctgc.m:
compiler/rbmm.add_rbmm_goal_infos.m:
compiler/rbmm.live_region_analysis.m:
compiler/structure_reuse.domain.m:
compiler/structure_reuse.versions.m:
compiler/structure_sharing.domain.m:
compiler/switch_detection.m:
compiler/term_constr_fixpoint.m:
compiler/term_constr_util.m:
compiler/tupling.m:
deep_profiler/analysis_utils.m:
deep_profiler/autopar_annotate.m:
deep_profiler/autopar_calc_overlap.m:
deep_profiler/recursion_patterns.m:
deep_profiler/var_use_analysis.m:
Avoid calling the newly obsolete predicates.
|
||
|
|
4ef4402ecf |
Make --warn-inconsistent-pred-order-clauses default for the compiler.
compiler/COMP_FLAGS.in:
As above.
compiler/Mercury.options:
List the modules for we need --no-warn-inconsistent-pred-order-clauses
for now.
compiler/call_gen.m:
compiler/code_util.m:
compiler/deep_profiling.m:
compiler/equiv_type.m:
compiler/error_util.m:
compiler/exprn_aux.m:
compiler/get_dependencies.m:
compiler/global_data.m:
compiler/layout_out.m:
compiler/liveness.m:
compiler/ll_pseudo_type_info.m:
compiler/llds.m:
compiler/llds_out_code_addr.m:
compiler/llds_out_data.m:
compiler/module_cmds.m:
compiler/module_qual.m:
compiler/module_qual.qualify_items.m:
compiler/opt_debug.m:
compiler/parse_class.m:
compiler/parse_goal.m:
compiler/parse_sym_name.m:
compiler/parse_type_defn.m:
compiler/rtti_out.m:
compiler/stack_layout.m:
compiler/trace_gen.m:
Fix issues reported by --warn-inconsistent-pred-order-clauses
for these modules.
|
||
|
|
6226b762bd | Simplify some code. | ||
|
|
83e2f21a81 |
Ignore NumErrors in one central place.
compiler/error_util.m:
For each predicate that writes out one or more error_specs, provide
a version that does not return the numbers of warnings and errors
written out.
compiler/deps_map.m:
compiler/find_module.m:
compiler/generate_dep_d_files.m:
compiler/handle_options.m:
compiler/make.module_dep_file.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_main.m:
compiler/modes.m:
compiler/options_file.m:
compiler/pd_util.m:
compiler/recompilation.check.m:
compiler/typecheck.m:
compiler/write_module_interface_files.m:
Replace calls write_error_{spec,specs} that ignored NumWarnings
and NumErrors with calls to the versions that do not return those
counts in the first place.
|
||
|
|
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.
|
||
|
|
15aa457e12 | Delete $module arg from calls to unexpected. |