Estimated hours taken: 4
Merge in the changes from the existential_types_2 branch.
This change adds support for mode re-ordering of code involving
existential types. The change required modifying the order of the
compiler passes so that polymorphism comes before mode analysis,
so that mode analysis can check the modes of the `type_info' or
`typeclass_info' variables that polymorphism introduces, so that
it can thus re-order the code accordingly.
This change also includes some more steps towards making existential data
types work. In particular, you should be able to declare existentially
typed data types, the compiler will generate appropriate unification
and compare/3 routines for them, and deconstruction unifications for them
should work OK. However, currently there's no way to construct them
except via `pragam c_code', and we don't generate correct RTTI for them,
so you can't use `io__write' etc. on them.
library/private_builtin.m:
compiler/accumulator.m:
compiler/bytecode_gen.m:
compiler/check_typeclass.m:
compiler/clause_to_proc.m:
compiler/code_util.m:
compiler/common.m:
compiler/dead_proc_elim.m:
compiler/dependency_graph.m:
compiler/det_analysis.m:
compiler/det_report.m:
compiler/follow_code.m:
compiler/follow_vars.m:
compiler/goal_util.m:
compiler/higher_order.m:
compiler/hlds_goal.m:
compiler/hlds_out.m:
compiler/hlds_pred.m:
compiler/intermod.m:
compiler/lambda.m:
compiler/live_vars.m:
compiler/magic.m:
compiler/make_hlds.m:
compiler/mercury_compile.m:
compiler/mercury_to_c.m:
compiler/mode_errors.m:
compiler/mode_info.m:
compiler/mode_util.m:
compiler/modecheck_call.m:
compiler/modecheck_unify.m:
compiler/modes.m:
compiler/pd_cost.m:
compiler/polymorphism.m:
compiler/post_typecheck.m:
compiler/purity.m:
compiler/quantification.m:
compiler/rl_exprn.m:
compiler/rl_key.m:
compiler/simplify.m:
compiler/table_gen.m:
compiler/term_traversal.m:
compiler/type_util.m:
compiler/typecheck.m:
compiler/unify_gen.m:
compiler/unify_proc.m:
compiler/unique_modes.m:
compiler/unused_args.m:
compiler/notes/compiler_design.html:
doc/reference_manual.texi:
tests/hard_coded/typeclasses/Mmakefile:
tests/hard_coded/typeclasses/existential_data_types.m:
tests/hard_coded/typeclasses/existential_data_types.exp:
tests/warnings/simple_code.exp:
tests/hard_coded/Mmakefile:
tests/term/arit_exp.trans_opt_exp:
tests/term/associative.trans_opt_exp:
tests/term/pl5_2_2.trans_opt_exp:
tests/term/vangelder.trans_opt_exp:
tests/term/arit_exp.trans_opt_exp:
tests/term/associative.trans_opt_exp:
tests/term/pl5_2_2.trans_opt_exp:
tests/term/vangelder.trans_opt_exp:
tests/invalid/errors2.err_exp2:
tests/invalid/prog_io_erroneous.err_exp2:
tests/invalid/type_inf_loop.err_exp2:
tests/invalid/types.err_exp2:
tests/invalid/polymorphic_unification.err_exp:
tests/invalid/Mmakefile:
tests/warnings/simple_code.exp:
tests/debugger/queens.exp:
tests/hard_coded/Mmakefile:
tests/hard_coded/existential_reordering.m:
tests/hard_coded/existential_reordering.exp:
Merge in the changes from the existential_types_2 branch.
Estimated hours taken: 0.1
tests/warnings/simple_code.exp:
Undo previous change -- I had accidentally committed it on the
main branch rather than on the existential_types_2 branch.
Estimated hours taken: 8
Various changes to fix test case failures in the existential_types_2
branch.
compiler/simplify.m:
Delete a bogus sanity check that I had added, since the check
was failing even in cases which made perfect sense.
(This one was stopping the compiler from bootstrapping.)
Delete an obsolete XXX comment about something that has already
been fixed.
When converting polymorphic complicated unifications into
calls to unification procedures, we need to insert the
type_info variables into the goal_info non-locals set.
compiler/simplify.m:
compiler/det_report.m:
Fix a couple of old XXXs: issue warnings when optimizing away
goals with determinism failure or det goals that have no outputs.
This is needed to ensure that we still issue a warning for several
of the goals in tests/warnings/simple_code.m. The previous
warnings were no longer being issued because this optimization was
optimization away the relevant code before it could be warned about.
tests/warnings/simple_code.exp:
Update to reflect the new warnings.
compiler/dependency_graph.m:
Don't include imported modes of pseudo_imported predicates
(i.e. (in,in) modes of unification predicates) in the dependency
graph. The treatment of pseudo_imported predicates in
dependency_graph.m needs to match the way they are treated
by polymorphism.m and other parts of the compiler.
compiler/polymorphism.m:
Update the headvars field of the proc_info for imported procedures
to include the type_info variables. This is necessary because
some parts of the compiler (e.g. unused_args.m) depend on the
headvars field being valid even for imported procedures.
Also fix a bug introduced in my changes to polymorphism.m -- I was
passing down the wrong HeadVars to polymorphism__produce_existq_tvars.
compiler/post_typecheck.m:
compiler/purity.m:
Ensure that we always bind any unbound type variables to `void'
before running polymorphism, even if there were type errors.
This avoids some internal errors in polymorphism.m.
compiler/mercury_compile.m:
Fix a formatting error in one of the progress messages.
compiler/modes.m:
compiler/unique_modes.m:
Ensure that mode analysis always stops analysing things once the
instmap becomes unreachable. It already did this for conjunctions,
most of the time, but there were several other cases
(if-then-elses and switches) where it did not.
The aim of this change is to stop mode inference from creating
modes for procedures with initial insts `not_reached'.
compiler/modecheck_unify.m:
Handle the case where an unification is initially inferred as
a non-complicated unification, and then gets re-modechecked
with the instmap being unreachable. The code here was assuming
that a non-complicated unification can never get turned into
a complicated unification on re-modechecking, but `not_reached'
unifications where being classified as complicated.
The above change to modes.m and unique_modes.m should avoid this
situation, but I thought it was safest to fix the code here too,
just in case.
compiler/modes.m:
compiler/modecheck_call.m:
compiler/mode_util.m:
Pass the type down to normalise_inst and ensure that for type_info
types, it never return a unique inst. The aim is to stop mode
inference from inferring unique modes for the type_info arguments
introduce by polymorphism.m, since unique modes are never useful
for those arguments, and allowing mode inference to infer
unique modes for them leads to it inferring unnecessarily many modes.
(Without this change, the test case tests/valid/uniq_mode_inf_bug.m
fails, due to a bug in the existing mode inference stuff unrelated
to my polymorphism / existential types changes. The bug is that
modecheck_queued_procs needs to run ordinary mode analysis to a
fixpoint before running determinism analysis, etc.)
tests/hard_coded/Mmakefile:
Fix a bug: compile lp.m with the same options as bigtest.m.
Without this, bigtest was getting link errors due to unsatisfied
symbols in lp.m. The problem was due to bigtest.m being compiled
with intermodule optimization, and lp.m being compiled without
intermodule optimization. This lead to bigtest.o containing
inlined references to local routines in lp.m, but lp.o not exporting
those symbols because intermodule optimization had not been enabled
when it was compiled.
Estimated hours taken: 0.1
tests/warnings/simple_code.exp:
Update the line numbers in the expected output;
my previous change to simple_code.m added a comment
which caused the line numbers in the warnings to change.
Estimated hours taken: 1.5
Perform some minor simplifications in mode analysis,
so as to provide more information to unique mode analysis.
Previously unique_modes.m was reporting spurious errors
for tests/hard_coded/bidirectional.m, because modes.m
produced output containing a subgoal of the form
`disj([Goal, conj([disj([])]])' instead of just `Goal',
and the presence of a disjunction then caused unique mode
analysis to make overly conservative assumptions.
compiler/modes.m:
Ensure that we do not produce singleton conjunctions or disjunctions.
Also, if the result of mode checking a disjunct is a (nested)
disjunction, then merge it with the containing disjunction.
If the nested disjunction is the empty disjunction (fail),
then this means it will be deleted.
tests/hard_coded/Mmakefile:
Re-enable the test case bidirectional.m, since the compiler now
accepts it, due to the above change.
tests/warnings/simple_code.m:
tests/warnings/simple_code.exp:
Update this test case, because the above change meant that the
compiler no longer issues the warning about "this disjunct can
never succeed" in cases like this -- mode analysis will already
have optimized it away, before we even get to simplify.m (which
handles those kinds of warnings). This warning is not as
important as allowing bidirectional code.
Estimated hours taken: 0.1
tests/warnings/simple_code.m:
Update the output, which changed because the removal of
goals with no outputs was disabled (I think).
Estimated hours taken: 2
Fix a bug reported by Philip Dart where "this disjunct cannot succeed"
warnings for predicates using sub-typing in modes were being output
without a context.
compiler/hlds_goal.m
Add versions of true_goal and fail_goal which take
a context for the goal.
compiler/simplify.m
Pass a valid context to true_goal and fail_goal.
Only report most of the --warn-simple-code messages if they
occur for all modes of a predicate - this avoids spurious
"this disjunct cannot succeed" warnings for sub-typing.
compiler/det_report.m
Added det_report__is_any_mode_msg to return whether a
message should only be reported if it occurs for all modes
of a predicate.
compiler/passes_aux.m
Add a task type update_pred_error for use by simplify.m.