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.
compiler/prog_data_pragma.m:
Encode the requirement that a type_subst, which used to be a list
contain at least one element. This type is used only to represent
the type substitution in a type_spec pragma, and it a type specialization
using a type substitution containing no type variables is a no-op.
compiler/parse_pragma.m:
We already enforced this requirement when reading in type_spec pragmas,
but the new representation we now construct lets users of that
representation to depend on it without runtime tests.
compiler/add_pragma_type_spec.m:
Delete such a runtime test.
Simplify the related code, mostly by using the new maybe_error5 type
to avoid constructing return values that wore destined to be ignored.
compiler/maybe_error.m:
Add the maybe_error5 type to the existing maybe_errorN for N in {1,2,3,4}.
compiler/parse_tree_out_pragma.m:
Don't put parentheses around type substitution lists that contain
only one entry, since in that case, we won't have a comma separating
entries that, if not inside parentheses, would indicate an extra argument
in the type_spec pragma.
compiler/equiv_type.m:
compiler/hlds_pred.m:
compiler/layout_out.m:
compiler/module_qual.qualify_items.m:
compiler/pred_name.m:
compiler/recompilation.usage.m:
compiler/recompilation.version.m:
Conform to the changes above.
compiler/options_file.m:
Change the interface of three lookup predicates to return
either the information they are intended to look up, or a list of
error_specs, but not both. The old code would have made sense
if some error_specs generated during the lookup could be warnings,
but they are always errors.
compiler/make.build.m:
Do not make room for warnings in make build's setup, because
(a) the code that filled in that slot with info from options_file.m
could never put any warnings in there, and (b) most users of that
data structure ignored that slot anyway.
Don't take parameters that are unneeded after this change.
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.track_flags.m:
compiler/mercury_compile_main.m:
Conform to the changes above.
compiler/maybe_error.m:
Add a utility predicate.
compiler/du_type_layout.m:
Add a first draft of the code that will eventually get type representation
information from .int files. Invoke the new code only if undocumented,
developer-only experiment flags are set, and when invoked, compare
its output with the output of the old algorithm it is intended to
eventually replace.
The new code is not yet complete, and thus has not yet been tested.
compiler/prog_item.m:
Add a new field to the augmented compilation unit data type
that is intended to hold the .int file of the main module, the module
that the augmented compilation unit is for. For every module imported
by the main module, we read its .int or .int2 file and get the
representation information for the types they define from those files,
but we need this info for the main module's own types as well.
Add "need type representation information" as reason for reading
a .int file.
Break some types down into smaller types, to allow their components
to be manipulated individually by du_type_layout.m.
Start using uint8, not uint, in situations where we want to store
values that select bits in words, which fit into 6 bits.
Add XXXs where we could, and maybe should switch to uint8s.
Add extra documentation.
compiler/grab_modules.m:
Read in the main module's own .int file.
Replace a bool with a bespoke type.
compiler/module_imports.m:
Provide a slot for the main module's own interface file,
which will be used to set the new slot in augmented compilation units.
compiler/comp_unit_interface.m:
Put the exact same type_ctor_repn_map into .int2 files as .int files.
This should prevent the scenario where a compilation reads
e.g. mod_x.int2, gains access to the definitions of the exported types
of module mod_x, but then needs to read mod_x.int as well to find out
how those types are represented. Since neither type checking nor any
other semantic analysis pass pays any attention to type_repn items,
the additional type_repn items in mod_x.int2 cannot turn an otherwise
illegal program into a legal one.
compiler/hlds_data.m:
Clarify a comment.
compiler/maybe_error.m:
Provide a utility predicate.
compiler/prog_data.m:
Add XXXs about possible future improvements.
compiler/decide_type_repn.m:
compiler/equiv_type.m:
compiler/get_dependencies.m:
compiler/make_hlds_passes.m:
compiler/make_hlds_separate_items.m:
compiler/module_qual.collect_mq_info.m:
compiler/module_qual.m:
compiler/parse_tree_out.m:
compiler/parse_tree_out_type_repn.m:
compiler/parse_type_repn.m:
compiler/prog_item_stats.m:
compiler/write_deps_file.m:
Conform to the changes above.
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.
browser/*.m:
compiler/*.m:
deep_profiler/*.m:
library/*.m:
mdbcomp/*.m:
ssdb/*.m:
Specify the type constructor for every inst definition that lists
the functors that values of that type may be bound to.
In library/maybe.m, delete the inst maybe_errors/1, because
(a) its name is misleading, since it is for the maybe_error/1 type (no s),
and (b) there is already an inst with the non-misleading name maybe_error
which had an identical definition.
In compiler/dep_par_conj.m, delete two insts that were duplicates
of insts defined in hlds_goal.m, and replace references to them
accordingly.
compiler/polymorphism.m:
When it sees a curried predicate call, polymorphism converts it to an
explicit lambda expression in order to add the unifications that
construct the type_infos and/or typeclass_infos the call needs.
For this, it needs to know the call's determinism. If the predicate had
no declared determinism, we used to abort the compiler, which is
too drastic a response to a simple programmer error.
Change this so that in this situation, we simply report an error,
and record that it is not safe to continue the compilation process.
In reality, it is not safe to continue the compilation only of the
predicate that the lambda expression occurs in, but in the vast, vast
majority of cases, this should be more than good enough.
I did try to code this change so that we continued the compilation
of other predicates when this error occurs, but it turned out to be
a bit too complicated for the very small potential benefit. Nevertheless,
some of the changes below are the results of this attempt; I kept them
because they are useful in their own right.
Change the code for traversing the procedures of a predicate
to be more direct.
Put the access predicates in the poly_info type in the same order
as the fields they operate on.
compiler/error_util.m:
Allow recording that an error is discovered during the polymorphism pass.
compiler/mercury_compile_front_end.m:
If polymorphism finds errors, print their messages, and then stop;
don't continue to the later passes.
compiler/maybe_error.m:
New module, containing the maybeN types (taken from prog_io_utio.m)
and the safe_to_continue type (taken from modes.m). These are now
needed by polymorphism.m as well.
compiler/parse_tree.m:
compiler/notes/compiler_design.html:
Mention the new module.
compiler/options.m:
doc/user_guide.texi:
Delete the (undocumented, developer-only) --no-polymorphism option,
since its use cannot lead to anything other than a compiler abort,
and this won't change in the future.
compiler/hlds_pred.m:
Rename the "marker" type to "pred_marker", to clarify its purpose.
Rename the "attribute" type to "pred_attribute", for the same reason.
Make the pred_markers and attributes types true sets, not lists
masquerading as sets.
Add a predicate to add more than one marker at a time to a set of markers.
Delete an unused predicate.
Rename the functors of the can_process type to clarify its purpose.
(I tried to use it to record the presence of errors discovered by
polymorphism.m, and this did not work; these renames should spare
others a similar experience.)
Make the code that construct pred_infos build its components from first
field to last field, not in random order.
compiler/det_analysis.m:
Specialize an exported predicate to its actual uses.
compiler/hlds_out_pred.m:
Dump the cannot_process_yet flag for procedures that have them.
compiler/add_pragma.m:
compiler/add_pred.m:
compiler/complexity.m:
compiler/deforest.m:
compiler/equiv_type_hlds.m:
compiler/field_access.m:
compiler/goal_expr_to_goal.m:
compiler/higher_order.m:
compiler/inlining.m:
compiler/intermod.m:
compiler/lambda.m:
compiler/ml_accurate_gc.m:
compiler/modecheck_goal.m:
compiler/modecheck_unify.m:
compiler/modecheck_util.m:
compiler/modes.m:
compiler/prog_io.m:
compiler/prog_io_dcg.m:
compiler/prog_io_goal.m:
compiler/prog_io_item.m:
compiler/prog_io_mode_defn.m:
compiler/prog_io_mutable.m:
compiler/prog_io_pragma.m:
compiler/prog_io_sym_name.m:
compiler/prog_io_type_defn.m:
compiler/prog_io_typeclass.m:
compiler/prog_io_util.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
compiler/simplify_goal_unify.m:
compiler/ssdebug.m:
compiler/stm_expand.m:
compiler/superhomogeneous.m:
compiler/table_gen.m:
compiler/try_expand.m:
compiler/unify_proc.m:
Conform to the changes above.
tests/invalid/higher_order_no_detism.{m,err_exp}:
A new test case to test that the compiler does not abort, but generates
an error message when it sees a curried predicate call to a predicate with
no declared determinism.
tests/invalid/Mmakefile:
Enable the new test case.