Prepare for these new options, --warn-unnecessarily-private-instance and
--warn-inconsistent-instance-order, by
- moving some checks on instance declarations to a point in time
when the set of instance declarations in the module is complete, and
- adding a new field to instance declarations to record a context needed
for the second of the above warnings.
compiler/add_class.m
compiler/check_typeclass.m
Move some checks on instances from add_class.m, where they have to
work with incomplete data, to check_typeclass.m, where they have access
to all instance declarations. The tests moved are
- the test whether the abstract and concrete forms of an instance
specify the same constraints or not,
- the test for duplicate concrete instances, and
- the test for overlapping instances.
The new code can be, and is, much more systematic in looking for
inconsistencies between instance declarations. For example,
it distinguishes between duplicate and overlapping instance declarations,
whereas the old code did not. This allows it to generate more precise
messages.
We do in fact generate a new warning message, for duplicate abstract
instance declarations.
Crucially, the new code can also gather the information needed
for --warn-inconsistent-instance-order, although the gathered info
is then throw away. This will change soon.
Record phase_type_check as the phase of all the error_specs generated
in this module, not just most of them.
Avoid constructing doing a global traversal of the entire instance table
when a local traversal of just the part for one class_id will do.
Give some predicates more meaningful names.
compiler/hlds_class.m
To check whether abstract instance declarations are in the same order
as concrete instance declarations, check_typeclass.m needs to record,
with each concrete instance declaration, the context of the corresponding
abstract instance declaration (if any). Add a slot for this information.
Change instance_id from an equivalence type to a notag type,
to reduce the chances of values of that type being confused
with integers whose semantics is something else.
Document why the structure of the instance table is what it is.
compiler/base_typeclass_info.m
compiler/dead_proc_elim.m
compiler/higher_order.m
compiler/hlds_code_util.m
compiler/hlds_defns.m
compiler/hlds_out_typeclass_table.m
compiler/intermod.m
compiler/polymorphism_type_class_info.m
compiler/recompilation.usage.m
compiler/typeclasses.m
compiler/unused_imports.m
Conform to the change in hlds_class.m.
compiler/hlds_out_util.m
Add a utility function for use by new code in hlds_out_typeclass_table.m.
tests/invalid/incompatible_instance_constraints.err_exp
tests/invalid/missing_concrete_instance.err_exp
tests/invalid/typeclass_test_9.err_exp
Expect updated error messages.
tests/invalid/*.{m,err_exp}:
tests/misc_tests/*.m:
tests/mmc_make/*.m:
tests/par_conj/*.m:
tests/purity/*.m:
tests/stm/*.m:
tests/string_format/*.m:
tests/structure_reuse/*.m:
tests/submodules/*.m:
tests/tabling/*.m:
tests/term/*.m:
tests/trailing/*.m:
tests/typeclasses/*.m:
tests/valid/*.m:
tests/warnings/*.{m,exp}:
Make these tests use four-space indentation, and ensure that
each module is imported on its own line. (I intend to use the latter
to figure out which subdirectories' tests can be executed in parallel.)
These changes usually move code to different lines. For the tests
that check compiler error messages, expect the new line numbers.
browser/cterm.m:
browser/tree234_cc.m:
Import only one module per line.
tests/hard_coded/boyer.m:
Fix something I missed.
Estimated hours taken: 1
Branches: main
Emit an error if abstract instances in the implementation of a module do
not have a corresponding concrete instance.
compiler/check_typeclass.m:
Check that abstract instance declarations in the implementation
section of a module have a corresponding concrete instance
declaration somewhere. Emit an error if they don't.
tests/invalid/missing_concrete_instance.{m,err_exp}:
Extend this test case to cover the above situation.
Estimated hours taken: 1.5
Branches: main
Do not display the `For more information try recompiling with `-E'' prompt
unless we really mean it, i.e. there is actually more information available.
XXX This change is incomplete for the mode_errors module because that
module requires more substantial changes to make this work - I'll do
that as a separate diff.
compiler/globals.m
Add a new global (and access predicates) that keeps track of whether
we have any verbose error information that could be displayed if we
recompiled with `-E'.
compiler/mercury_compile.m
Check the new global flag before prompting the user to recompile with
`-E'.
compiler/mode_errors.m
Add an XXX comment about needing to respect the extra error info flag
properly.
compiler/accumulator.m
compiler/add_clause.m
compiler/add_pred.m
compiler/add_type.m
compiler/assertion.m
compiler/check_typeclass.m
compiler/det_report.m
compiler/magic_util.m
compiler/make_hlds_error.m
compiler/modes.m
compiler/module_qual.m
compiler/modules.m
compiler/post_typecheck.m
compiler/purity.m
compiler/stratify.m
compiler/typecheck_errors.m
Set the new global flag when we come across an error
for which we have a verbose error message.
tests/recompilation/*:
tests/invalid/*:
Update expected error files.
Estimated hours taken: 3
Branches: main, release
Have the compiler emit an error if an abstract instance declaration
in the interface of a module does not have a corresponding concrete
instance declaration in the implementation of the module. Currently
the compiler just ignores this situation which leads to C compilation
errors in the MLDS grades and link-time errors in the LLDS grades.
compiler/check_typeclass.m:
Emit an error message if an abstract instance declaration
in the interface of a module does not have a corresponding
concrete instance in the implementation.
Use unexpected/2 in place of error/2.
Fix the positioning of a few comments.
Add an end_module declaration.
compiler/hlds_data.m:
Make the instance_table type a multi_map (which it
already effectively was).
tests/invalid/Mmakefile:
tests/invalid/missing_concrete_instance.m:
tests/invalid/missing_concrete_instance.err_exp:
Test case for the above.