mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-20 11:54:02 +00:00
We used to include in the .int0 file the abstract form of all the instance
declarations in both the interface and the implementation sections.
When an instance is declared (in an already-abstract form) in the interface
section and defined in the implementation section, this resulted in the
abstract interface declaration being included in the .int0 file twice,
once in the interface section, and once in the implementation section.
compiler/comp_unit_interface.m:
Fix this by including an abstract instance declaration in the
implementation section of a .int0 file only if it does not also appear
in the interface section.
Conform to the changes in prog_item.m below.
compiler/parse_tree_out.m:
To help implement the above test, add a function to return the string
form of an abstract instance declaration.
It is easy to make this change for *abstract* instance declarations,
but not *concrete* instance definitions, because (in order to handle
instances that define methods by clauses, instead of by pred/func names)
the latter would require generalizing *all* the code for writing out
clauses, with all the overhead associated with replacing first order calls
with method calls.
Another change (unrelated to the problem above) is to write out
typeclass and instance definitions for typeclasses with no methods
in a nicer form. Instead of looking like this:
:- instance classname(argtypes) where [
].
they now look like this:
:- instance classname(argtypes) where [].
Another formatting change unrelated to the above: don't put parentheses
around typeclass names in instance declarations/definitions if the name
is all alphanumeric and not an operator.
Conform to the changes in prog_item.m below.
compiler/prog_data.m:
compiler/prog_item.m:
To be able to use the new code to convert abstract instances to strings
in comp_unit_interface, and to write out abstract instance declarations
inside .int0 (and other .intN) files, it helps to know which instance
items can only be abstract in these files. As it turns out, none can be
concrete. So define a subtype of item_instance_info that can contain
only abstract instance declarations, and use it to replace
item_instance_info in parse_tree_intN for all N.
compiler/parse_tree_out_info.m:
Add a utility function for new code in comp_unit_interface.m
invoking new code in parse_tree_out.m.
compiler/convert_parse_tree.m:
Conform to the changes in prog_item.m by insisting that instances
read in from .intN files are all abstract.
Fix some typos in some error messages (which people can see only if
something has screwed up a .intN file).
compiler/equiv_type.m:
compiler/get_dependencies.m:
compiler/make_hlds_separate_items.m:
compiler/module_qual.collect_mq_info.m:
compiler/module_qual.qualify_items.m:
compiler/recompilation.version.m:
Conform to the changes above.
compiler/intermod.m:
Simplify some code.
tests/invalid/Mercury.options:
Fix the failure of the instances_pc.instances_pc_helper_1 test case
when intermodule optimization is enabled for a bootcheck by disabling
intermodule optimization for this test. The old code to do so didn't
work due to typos.
tests/invalid/instances_pc.instances_pc_helper_1.err_exp:
Expect a reference to only ONE old instance declaration in
instances_pc.int0. Expect it at a new line number, due to the first
formatting change above.
tests/misc_tests/pretty_print_test.exp:
Expect no unnecessary parentheses around a class name in an
instance definition, due to the second formatting change.