Estimated hours taken: 0.5
Fix bugs that were stopping *.res and *.out files being cleaned up properly.
tests/Mmake.common:
tests/general/accumulator/Mmakefile:
tests/invalid/Mmakefile:
tests/misc_tests/Mmakefile:
tests/tabling/Mmakefile:
tests/term/Mmakefile:
tests/valid/Mmakefile:
tests/warnings/Mmakefile:
Make cleaning tasks depend on (real)clean_local rather than
(real)clean. This is because tests/startup and tests/shutdown
use the *_local targets.
tests/general/Mmakefile:
Fix bugs in the recursive mmake calls.
Estimated hours taken: 0.25
compiler/unique_modes.m:
The argument offset for higher-order calls was being set
to 0, not 1 (the higher-order term is not included in
the argument list). This resulted in the argument numbers
in error messages for higher-order calls being one less
than expected.
tests/invalid/Mmakefile:
tests/invalid/ho_unique_error.m:
tests/invalid/ho_unique_error.err_exp:
Test case.
Estimated hours taken: 0.1
compiler/post_typecheck.m:
Fix a cut and paste error - `aditi_modify' goals were
being transformed into `aditi_delete' goals.
tests/invalid/aditi_update_mode_errors.m:
Fix the expected output.
Estimated hours taken: 220
Aditi update syntax, type and mode checking.
Change the hlds_goal for constructions in preparation for
structure reuse to avoid making multiple conflicting changes.
compiler/hlds_goal.m:
Merge `higher_order_call' and `class_method_call' into a single
`generic_call' goal type. This also has alternatives for the
various Aditi builtins for which type declarations can't
be written.
Remove the argument types field from higher-order/class method calls.
It wasn't used often, and wasn't updated by optimizations
such as inlining. The types can be obtained from the vartypes
field of the proc_info.
Add a `lambda_eval_method' field to lambda_goals.
Add a field to constructions to identify which RL code fragment should
be used for an top-down Aditi closure.
Add fields to constructions to hold structure reuse information.
This is currently ignored -- the changes to implement structure
reuse will be committed to the alias branch.
This is included here to avoid lots of CVS conflicts caused by
changing the definition of `hlds_goal' twice.
Add a field to `some' goals to specify whether the quantification
can be removed. This is used to make it easier to ensure that
indexes are used for updates.
Add a field to lambda_goals to describe whether the modes were
guessed by the compiler and may need fixing up after typechecking
works out the argument types.
Add predicate `hlds_goal__generic_call_id' to work out a call_id
for a generic call for use in error messages.
compiler/purity.m:
compiler/post_typecheck.m:
Fill in the modes of Aditi builtin calls and closure constructions.
This needs to know which are the `aditi__state' arguments, so
it must be done after typechecking.
compiler/prog_data.m:
Added `:- type sym_name_and_arity ---> sym_name/arity'.
Add a type `lambda_eval_method', which describes how a closure
is to be executed. The alternatives are normal Mercury execution,
bottom-up execution by Aditi and top-down execution by Aditi.
compiler/prog_out.m:
Add predicate `prog_out__write_sym_name_and_arity', which
replaces duplicated inline code in a few places.
compiler/hlds_data.m:
Add a `lambda_eval_method' field to `pred_const' cons_ids and
`pred_closure_tag' cons_tags.
compiler/hlds_pred.m:
Remove type `pred_call_id', replace it with type `simple_call_id',
which combines a `pred_or_func' and a `sym_name_and_arity'.
Add a type `call_id' which describes all the different types of call,
including normal calls, higher-order and class-method calls
and Aditi builtins.
Add `aditi_top_down' to the type `marker'.
Remove `aditi_interface' from type `marker'. Interfacing to
Aditi predicates is now handled by `generic_call' hlds_goals.
Add a type `rl_exprn_id' which identifies a predicate to
be executed top-down by Aditi.
Add a `maybe(rl_exprn_id)' field to type `proc_info'.
Add predicate `adjust_func_arity' to convert between the arity
of a function to its arity as a predicate.
Add predicates `get_state_args' and `get_state_args_det' to
extract the DCG state arguments from an argument list.
Add predicate `pred_info_get_call_id' to get a `simple_call_id'
for a predicate for use in error messages.
compiler/hlds_out.m:
Write the new representation for call_ids.
Add a predicate `hlds_out__write_call_arg_id' which
replaces similar code in mode_errors.m and typecheck.m.
compiler/prog_io_goal.m:
Add support for `aditi_bottom_up' and `aditi_top_down' annotations
on pred expressions.
compiler/prog_io_util.m:
compiler/prog_io_pragma.m:
Add predicates
- `prog_io_util:parse_name_and_arity' to parse `SymName/Arity'
(moved from prog_io_pragma.m).
- `prog_io_util:parse_pred_or_func_name_and_arity to parse
`pred SymName/Arity' or `func SymName/Arity'.
- `prog_io_util:parse_pred_or_func_and_args' to parse terms resembling
a clause head (moved from prog_io_pragma.m).
compiler/type_util.m:
Add support for `aditi_bottom_up' and `aditi_top_down' annotations
on higher-order types.
Add predicates `construct_higher_order_type',
`construct_higher_order_pred_type' and
`construct_higher_order_func_type' to avoid some code duplication.
compiler/mode_util.m:
Add predicate `unused_mode/1', which returns `builtin:unused'.
Add functions `aditi_di_mode/0', `aditi_ui_mode/0' and
`aditi_uo_mode/0' which return `in', `in', and `out', but will
be changed to return `di', `ui' and `uo' when alias tracking
is implemented.
compiler/goal_util.m:
Add predicate `goal_util__generic_call_vars' which returns
any arguments to a generic_call which are not in the argument list,
for example the closure passed to a higher-order call or
the typeclass_info for a class method call.
compiler/llds.m:
compiler/exprn_aux.m:
compiler/dupelim.m:
compiler/llds_out.m:
compiler/opt_debug.m:
Add builtin labels for the Aditi update operations.
compiler/hlds_module.m:
Add predicate predicate_table_search_pf_sym, used for finding
possible matches for a call with the wrong number of arguments.
compiler/intermod.m:
Don't write predicates which build `aditi_top_down' goals,
because there is currently no way to tell importing modules
which RL code fragment to use.
compiler/simplify.m:
Obey the `cannot_remove' field of explicit quantification goals.
compiler/make_hlds.m:
Parse Aditi updates.
Don't typecheck clauses for which syntax errors in Aditi updates
are found - this avoids spurious "undefined predicate `aditi_insert/3'"
errors.
Factor out some common code to handle terms of the form `Head :- Body'.
Factor out common code in the handling of pred and func expressions.
compiler/typecheck.m:
Typecheck Aditi builtins.
Allow the argument types of matching predicates to be adjusted
when typechecking the higher-order arguments of Aditi builtins.
Change `typecheck__resolve_pred_overloading' to take a list of
argument types rather than a `map(var, type)' and a list of
arguments to allow a transformation to be performed on the
argument types before passing them.
compiler/error_util.m:
Move the part of `report_error_num_args' which writes
"wrong number of arguments (<x>; expected <y>)" from
typecheck.m for use by make_hlds.m when reporting errors
for Aditi builtins.
compiler/modes.m:
compiler/unique_modes.m:
compiler/modecheck_call.m:
Modecheck Aditi builtins.
compiler/lambda.m:
Handle the markers for predicates introduced for
`aditi_top_down' and `aditi_bottom_up' lambda expressions.
compiler/polymorphism.m:
Add extra type_infos to `aditi_insert' calls
describing the tuple to insert.
compiler/call_gen.m:
Generate code for Aditi builtins.
compiler/unify_gen.m:
compiler/bytecode_gen.m:
Abort on `aditi_top_down' and `aditi_bottom_up' lambda
expressions - code generation for them is not yet implemented.
compiler/magic.m:
Use the `aditi_call' generic_call rather than create
a new procedure for each Aditi predicate called from C.
compiler/rl_out.pp:
compiler/rl_gen.m:
compiler/rl.m:
Move some utility code used by magic.m and call_gen.m into rl.m.
Remove an XXX comment about reference counting being not yet
implemented - Evan has fixed that.
library/ops.m:
compiler/mercury_to_mercury.m:
doc/transition_guide.texi:
Add unary prefix operators `aditi_bottom_up' and `aditi_top_down',
used as qualifiers on lambda expressions.
Add infix operator `==>' to separate the tuples in an
`aditi_modify' call.
compiler/follow_vars.m:
Thread a `map(prog_var, type)' through, needed because
type information is no longer held in higher-order call goals.
compiler/table_gen.m:
Use the `make_*_construction' predicates in hlds_goal.m
to construct constants.
compiler/*.m:
Trivial changes to add extra fields to hlds_goal structures.
doc/reference_manual.texi:
Document Aditi updates.
Use @samp{pragma base_relation} instead of
@samp{:- pragma base_relation} throughout the Aditi documentation
to be consistent with other parts of the reference manual.
tests/valid/Mmakefile:
tests/valid/aditi_update.m:
tests/valid/aditi.m:
Test case.
tests/valid/Mmakefile:
Remove some hard-coded --intermodule-optimization rules which are
no longer needed because `mmake depend' is now run in this directory.
tests/invalid/*.err_exp:
Fix expected output for changes in reporting of call_ids
in typecheck.m.
tests/invalid/Mmakefile
tests/invalid/aditi_update_errors.{m,err_exp}:
tests/invalid/aditi_update_mode_errors.{m,err_exp}:
Test error messages for Aditi updates.
tests/valid/aditi.m:
tests/invalid/aditi.m:
Cut down version of extras/aditi/aditi.m to provide basic declarations
for Aditi compilation such as `aditi__state' and the modes
`aditi_di', `aditi_uo' and `aditi_ui'. Installing extras/aditi/aditi.m
somewhere would remove the need for these.
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: 1
compiler/hlds_goal.m:
Added `set_goal_contexts', which sets all the contexts
of the goal_infos of the sub-goals of a goal.
compiler/unify_proc.m:
Use `set_goal_contexts' to ensure that error messages
for automatically generated procedures have a useful context.
tests/invalid/partial_implied_mode.err_exp:
Update the expected output.
Estimated hours taken: 0.1
tests/invalid/partial_implied_mode.err_exp:
Update the line numbers which changed after Zoltan's
change to stop putting #line directives in .int files.
Estimated hours taken: 10
Fix a code generator abort reported by Stephane Marie
<stephane.marie@detexis.thomson-csf.com>.
The bug was in the code to work out the instmap after a deconstruction
unification with complicated sub-unifications.
The instmap_delta for the unification contained only the bindings for
the first argument for which a new variable was created.
The test case now gives an error during mode analysis
rather than a code generator abort (for unification procedures
of imported types) or a mode error during unique mode analysis
(for local types).
compiler/modes.m:
compiler/modecheck_call.m:
compiler/modecheck_unify.m:
Simplify the code to handle extra goals by not attempting
to bodge together the instmap after the main goal.
Instead, the code now creates the extra unifications and
rechecks the goal with the unifications added.
compiler/mode_info.m:
Add a field to say whether we are reprocessing a goal after
adding extra goals. Abort if the reprocessing adds more extra goals.
The `may_changed_called_proc' field is now separate from
the `how_to_check_goal' field. This is used to avoid
repeating the search for the best procedure when rerunning
mode analysis after adding the extra goals.
compiler/modecheck_unify.m:
Removed predicate unify_vars - it is no longer used.
compiler/unify_proc.m:
Call module_info_remove_predid if there are mode errors
in a unification procedure to avoid spurious determinism
errors.
tests/hard_coded/Mmakefile:
tests/hard_coded/partial_implied_mode.m:
tests/hard_coded/partial_implied_mode.err_exp:
Test case. It would be nicer if the error message pointed
to the unification which caused the unification procedure
to be created, rather than the type declaration in the
interface file.
Estimated hours taken: 60
User-guided type specialization.
compiler/prog_data.m:
compiler/prog_io_pragma.m:
compiler/modules.m:
compiler/module_qual.m:
compiler/mercury_to_mercury.m:
Handle `:- pragma type_spec'.
compiler/prog_io_pragma.m:
Factor out some common code to parse predicate names with arguments.
compiler/hlds_module.m:
Added a field to the module_sub_info to hold information about
user-requested type specializations, filled in by make_hlds.m
and not used by anything after higher_order.m.
compiler/make_hlds.m:
For each `:- pragma type_spec' declaration, introduce a new predicate
which just calls the predicate to be specialized with the
specified argument types. This forces higher_order.m to produce
the specialized versions.
compiler/higher_order.m:
Process the user-requested type specializations first to ensure
that they get the correct names.
Allow partial matches against user-specified versions, e.g.
map__lookup(map(int, list(int)), int, list(int)) matches
map__lookup(map(int, V), int, V).
Perform specialization where a typeclass constraint matches a
known instance, but the construction of the typeclass_info is
done in the calling module.
Give slightly more informative progress messages.
compiler/dead_proc_elim.m:
Remove specializations for dead procedures.
compiler/prog_io_util.m:
Change the definition of the `maybe1' and `maybe_functor' types
to avoid the need for copying to convert between `maybe1'
and `maybe1(generic)'.
Changed the interface of `make_pred_name_with_context' to allow
creation of predicate names for type specializations which describe
the type substitution.
compiler/make_hlds.m:
compiler/prog_io_pragma.m:
Make the specification of pragma declarations in error
messages consistent. (There are probably some more to
be fixed elsewhere for termination and tabling).
compiler/intermod.m:
Write type specialization pragmas for predicates declared
in `.opt' files.
compiler/mercury_to_mercury.m:
Export `mercury_output_item' for use by intermod.m.
compiler/options.m:
Add an option `--user-guided-type-specialization' enabled
with `-O2' or higher.
compiler/handle_options.m:
`--type-specialization' implies `--user-guided-type-specialization'.
compiler/hlds_goal.m:
Add predicates to construct constants. These are duplicated
in several other places, I'll fix that as a separate change.
compiler/type_util.m:
Added functions `int_type/0', `string_type/0', `float_type/0'
and `char_type/0' which return the builtin types.
These are duplicated in several other places,
I'll fix that as a separate change.
library/private_builtin.m:
Added `instance_constraint_from_typeclass_info/3' to extract
the typeclass_infos for a constraint on an instance declaration.
This is useful for specializing class method calls.
Added `thread_safe' to various `:- pragma c_code's.
Added `:- pragma inline' declarations for `builtin_compare_*', which
are important for user-guided type specialization. (`builtin_unify_*'
are simple enough to go in the `.opt' files automatically).
compiler/polymorphism.m:
`instance_constraint_from_typeclass_info/3' does not need type_infos.
Add `instance_constraint_from_typeclass_info/3' to the
list of `typeclass_info_manipulator's which higher_order.m
can interpret.
NEWS:
doc/reference_manual.texi:
doc/user_guide.texi
Document the new pragma and option.
tests/invalid/Mmakefile:
tests/invalid/type_spec.m:
tests/invalid/type_spec.err_exp:
Test error reporting for invalid type specializations.
tests/hard_coded/Mmakefile:
tests/invalid/type_spec.m:
tests/invalid/type_spec.exp:
Test type specialization.
Estimated hours taken: 4
Fix a bug in unique mode checking.
compiler/unique_modes.m:
Fix a bug reported by Serge Varennes
<serge.varennes@detexis.thomson-csf.com>:
we need to mark variables as `mostly_unique' rather
than `unique' at all disjunctions, not just at model_non
disjunctions, because model_semi and even model_det
disjunctions can still have backtracking from one failing
disjunct into the next disjunct.
Also add a couple of comments.
tests/invalid/Mmakefile:
tests/invalid/uniq_modes.m:
tests/invalid/uniq_modes.err_exp:
Add a regression test for this change.
tests/hard_coded/purity.m:
tests/hard_coded/cc_nondet_disj.m:
Fix code that the compiler now rejects, due to the above change.
The compiler is being a bit conservative to reject these cases,
because the code won't actually violate unique-mode-correctness,
but the conservatism here with disjunctions is similar to unique
mode analysis's already existing conservatism with regard to
if-then-elses, and the work-around for cases like this is easy,
so I don't consider that to be a significant problem.
The conservatism in question is that if it sees
`{ test }, io__write_string("blah")' in a model_det/model_semi
disjunct or in the condition of an if-then-else, it will report
a unique mode error, since it doesn't realize that destructive
update only occurs _after_ we have committed to this branch.
tests/hard_coded/Mmakefile:
Disable the test case bidirectional.m, since the compiler now
rejects it, due to the above change to unique_modes.m.
The compiler is again being overly conservative in its analysis.
The problem is similar to that in the two test cases above,
unfortunately there is no easy work-around in this case.
The compiler really ought to support this style of bidirectional
code using unique modes, so I do consider this to be a significant
problem, but the fix is a fair bit of work, so I will deal with
that as a separate change.
Estimated hours taken: 1
Avoid some spurious flow-on diagnostics.
compiler/mercury_compile.m:
Pass down a boolean indicating whether we got any type errors
to purity.m.
compiler/purity.m:
Only call post_typecheck__check_type_bindings if we didn't get
any type errors, because if we did get any type errors, then
calling check_type_bindings may lead to a lot of spurious
diagnostics.
tests/invalid/types.err_exp:
tests/invalid/errors2.err_exp:
Update the expected error messages for these test cases to
reflect the fact that we no longer warnings in these cases.
Estimated hours taken: 9
Implement abstract instance declarations.
compiler/prog_data.m:
Rename the `instance_interface' type as `instance_body',
and make it a discriminated union: either `abstract',
or `concrete(Methods)'.
compiler/prog_io_typeclass.m:
compiler/hlds_data.m:
compiler/hlds_out.m:
compiler/equiv_type.m:
compiler/check_typeclass.m:
Change the code to reflect the new name and representation
of `instance_interface'.
compiler/prog_io_typeclass.m:
Parse abstract instance declarations.
compiler/make_hlds.m:
Clean up the code a bit, and make sure that it detects some errors
which previously we didn't detect: duplicate or overlapping
instance declarations, and instance declarations with methods for
classes with no methods.
compiler/check_typeclass.m:
If an instance is abstract, then we don't need to check
that the methods in the instance body match those in the class.
compiler/base_typeclass_info.m:
Only generate base_typeclass_infos for concrete instance
declarations, not for abstract ones.
doc/reference_manual.texi:
Document the change.
tests/hard_coded/typeclasses/Mmakefile:
tests/hard_coded/typeclasses/abstract_instance.m:
tests/hard_coded/typeclasses/use_abstract_instance.m:
tests/hard_coded/typeclasses/use_abstract_instance.exp:
tests/invalid/Mmakefile:
tests/invalid/typeclass_test_9.m:
tests/invalid/typeclass_test_9.err_exp:
Some test cases.
tests/hard_coded/typeclasses/Mmakefile:
Uncomment typeclass_test_5.m, since we pass that now
(and have done so for quite some time).
tests/invalid/typeclass_test_[3-5].err_exp:
Update to reflect additional error messages produced
by the improved error checking in compiler/make_hlds.m.
Estimated hours taken: 0.1
tests/invalid/any_mode.err_exp
The compiler no longer assumes that a predicate with
no type declaration is local. This results in extra
errors for this test case about there being no
determinism declaration for an exported predicate.
Estimated hours taken: 1
compiler/check_typeclass.m:
Add an indication of whether or not the type class method for which
we are reporting an error is a predicate or a function.
tests/invalid/typeclass_test_3.err_exp:
tests/invalid/typeclass_test_4.err_exp:
tests/invalid/typeclass_test_5.err_exp:
Updated to reflect the new error message format.
Estimated hours taken: 0.5
tests/invalid/some.err_exp:
tests/invalid/predmode.err_exp:
tests/invalid/func_errors.err_exp:
Update the test results to reflect the extra parentheses
now printed out by term_io__write_term.
Estimated hours taken: 0.25
tests/invalid/errors.err_exp:
tests/invalid/vars_in_wrong_places.err_exp:
Update the test results to reflect the new variable numbers
printed out by term_io__write_term.
Estimated hours taken: 2
compiler/polymorphism.m:
Abort if there is a polymorphic unification that is in
a partially instantiated mode. This error should be
caught earlier (probably during mode analysis), but it's
best to abort rather than just go ahead and generate
bad code.
tests/invalid/polymorphic_unification.m:
tests/invalid/polymorphic_unification.err_exp:
A test case for the above change.
tests/invalid/Mmakefile:
Turn this test case on.
Estimated hours taken: 0.75
Report an error if the first argument of a `some' goal
is not a list of variables.
compiler/prog_io.m:
compiler/prog_io_util.m:
Move `parse_list_of_vars' from prog_io.m to prog_io_util.m.
compiler/prog_io_goal.m:
Check to make sure that the first argument to a some
goal is a list of variables. (If not, we don't report
an error here -- the error will be reported by typecheck.m.)
compiler/typecheck.m:
Report an proper error message if there is a call to an
undefined predicate `some/2'.
Also add `some/2' and `all/2' to the list of language builtins
for which we report a special error message if they occur as
undefined function symbols.
tests/invalid/Mmakefile:
tests/invalid/some.m:
tests/invalid/some.err_exp:
Regression test for the above change.
Estimated hours taken: 1
Minor improvements to some compiler error messages.
compiler/modules.m:
Fix a missing close-quote in an error message.
Also improve the wording of the message slightly.
compiler/check_typeclass.m:
compiler/typecheck.m:
Add quotes (`...') in a couple of places
tests/invalid/sub*.err_exp:
tests/invalid/typeclass_test*.err_exp:
Update to reflect the new error messages.
tests/invalid/Mmakefile:
Delete an obsolete comment about a poor error message.
Estimated hours taken: 0.1
tests/invalid/Mmakefile:
Fix a typo in a previous change of mine: I had
accidentally added `uu_type' instead of `uu_type.m'
to the list of source files.
Estimated hours taken: 6
Fix a bug where type errors were causing spurious mode errors,
compiler/post_typecheck.m:
Add new predicate post_typecheck__ill_typed_pred,
which just module-qualifies the pred declaration for that pred.
This is necessary to avoid spurious mode errors in predicates
that call the ill-typed pred.
compiler/typecheck.m:
Call post_typecheck__ill_typed_pred on ill-typed predicates
before calling module_info_remove_pred. We need to call it
here because later passes won't process the pred once it
has been removed.
tests/invalid/Mmakefile:
tests/invalid/spurious_mode_error.m:
tests/invalid/spurious_mode_error.err_exp:
Regression test for the above-mentioned bug.
Estimated hours taken: 0.25
tests/warnings/Mmakefile:
tests/warnings/uu_type.m:
tests/warnings/uu_type.exp:
tests/invalid/Mmakefile:
tests/invalid/uu_type.m:
tests/invalid/uu_type.err_exp:
Move the `uu_type' test case from the `warnings' directory
to the `invalid' directory, since the compiler reports an
error rather than a warning. This also fixes a problem where
the hard-coded rule for `uu_type.err' in tests/warnings/Mmakefile
broke things (e.g. it broke `tools/bootcheck --use-subdirs').
Estimated hours taken: 1
compiler/modules.m:
compiler/mercury_compile.m:
Warn about modules with no exports when compiling,
not just when making interfaces. Previous it would
only issue this warning when doing `mmc --make-int',
not when doing `mmc --compile-to-c'.
tests/invalid/Mmakefile:
tests/invalid/no_exports.err_exp:
Enable the already-existing test case for this.
Estimated hours taken: 0.5
tests/invalid/Mmakefile:
Disable the `sub_b' and `sub_c' test cases, since we don't pass
them (due to a bug with the auto-generated Mmake dependencies
for nested modules).
Enable the `typeclass_test_7' test case, since we do pass it now.
tests/invalid/typeclass_test_7.err_exp:
Update to reflect the proper output for this test case:
s/unsatisfied/unsatisfiable/
Estimated hours taken: 0.1
Add a test case for the changes to the undefined symbol error message.
tests/invalid/undef_symbol.{m,err_exp}:
Add a test to make sure we get the error message right if the
undefined symbol is qualified with the current module name.
Estimated hours taken: 4
compiler/typecheck.m:
Fix a bug which resulted in the compiler aborting with a
map_lookup failure for certain (ill-typed) code.
tests/invalid/Mmakefile:
tests/invalid/ext_type_bug.m:
tests/invalid/ext_type_bug.err_exp:
Regression test for the above-mention bug.
Estimated hours taken: 0.25
tests/invalid/sub_c.err_exp:
Fix the expected output for this test case.
(I had accidentally done `cp sub_c.m sub_c.err_exp'
instead of `cp sub_c.err sub_c.err_exp'.)
Estimated hours taken: 3.5
Fix a bug reported by Warwick Harvey <wharvey@cs.monash.edu.au>
where importing a nested module without first importing the
parent module resulted in a software error when building the
dependencies.
compiler/modules.m:
Change a call to `map__det_insert' into `map__set',
to avoid a `map__det_insert failed' error,
and add some detailed comments explaining why.
tests/invalid/Mmakefile:
tests/invalid/sub_a.m:
tests/invalid/sub_b.m:
tests/invalid/sub_b.err_exp:
tests/invalid/sub_c.m:
tests/invalid/sub_c.err_exp:
Add a couple of test cases.
Estimated hours taken: 0.1
Add a test case for the changes to the undefined symbol error message.
tests/invalid/Mmakefile:
Add the new test case.
tests/invalid/undef_symbol.{m,err_exp}:
The new test case.
Estimated hours taken: 0.2
Test cases for the type class error messages.
invalid/typeclass_test_[3,4].err_exp:
Updated to use the new error message format.
invalid/Mmakefile:
Turn on the new test case.
invalid/typeclass_test_5.m:
New test case for unsatisfied superclass constraints and multiply
defined instance methods.
Estimated hours taken: 2
Prevent compiler aborts by preventing uu types from reaching any pass after
the front end. You can get such types when you unintentionally use the
syntax reserved for undiscriminated union types, by writing
:- type type1 = type2.
instead of
:- type type1 == type2.
This fixes a problem reported by Bart.
compiler/make_hlds.m:
Handle references to uu types as errors, not warnings. Change the
message accordingly.
tests/warnings/uu_type.{m,exp}:
A test case for the new handling of uu types, contributed by Bart.
tests/warnings/Mmakefile:
Enable the test case.
tests/invalid/bigtest.err_exp:
Update expected error message.
Estimated hours taken: 1.5
tests/debugger/Mmakefile:
Disable the queens test, which is has output that doesn't
seem to match its input.
tests/invalid/Mmakefile:
Generate dependencies for nested_impl_in_int, but don't
try to build it any further.
This detects the error, but avoids trying to build the entire
program.
Estimated hours taken: 0.01
tests/invalid/Mmakefile:
Enable the test case nested_impl_in_int.m (I forgot to change
the Mmakefile when adding this test case).
Estimated hours taken: 5
Implement some parts of the support for nested modules that I had
forgotten about.
compiler/modules.m:
Allow the `:- interface' and `:- implementation' parts of
nested modules to be separated.
Check that `:- implementation' declarations for nested
modules don't occur in the interface section of the parent module.
tests/hard_coded/nested3.m:
tests/hard_coded/nested3.exp:
tests/invalid/nested_impl_in_int.m:
tests/invalid/nested_impl_in_int.err_exp:
Test cases for the above-mentioned feature.
tests/hard_coded/Mmakefile:
Add `RM_C=:', so that the nested modules tests work with
parallel makes, and then enable those tests.
Estimated hours taken: 0.25
tests/invalid/typeclass_test_[12].err_exp:
Update to reflect a trivial modification to an error message
in my existential types changes: s/unsatisfied/unsatisfiable/
Estimated hours taken: 6
(plus another 80 or so already recorded for
my commits on the existential_types branch)
Merge in the changes from the existential types branch,
and make some modifications to address dgj's code review comments.
These changes add support for existentially quantified type variables
and type class constraints on functions and predicates.
(Existential data types, however, are not supported -- see below.)
Existentially quantified type variables are introduced with
an explicit `some [T]', e.g. `:- some [T] pred foo(T)'.
Existentially quantified type class constraints are introduced
with `&' instead of `<=', e.g. `:- some [T] (pred foo(T) & ord(T))'.
There's still several limitations:
0. XXX It's not yet documented in the language reference manual.
1. XXX It doesn't do any mode checking or mode reordering.
If you write code that uses existentially typed procedures in the
wrong order, then you'll get an internal error in polymorphism.m
or in the code generator. (Cases where a type_info has no
producer at all are caught by the check for unbound type
variables in post_typecheck.m.)
To support this, we need to change things so that polymorphism.m
gets invoked before mode checking.
2. Using `in' modes on arguments of existential type won't work.
If you try, you will get a compile error.
It would be nice to extend things to allow this kind of
"implied mode" for type_infos, where an existential type
becomes a universal type if some value of that type is
input. Supporting this would require first fixing
limitation 1 (described above) and then
3. There's no support for `pragma c_code' for procedures
with existential type class constraints.
(In fact, there's not really any support for `pragma c_code'
for procedures with universal type class constraints either --
the C code has no way of getting access to the type class info.)
4. XXX Taking the address of something which is existentially typed
should be illegal, but we don't check this.
In addition, these changes in this batch make a start towards allowing
existentially typed data types. The compiler now accepts existential
quantifiers and type class constraints on type definitions, and type
checks them accordingly (assuming all functor occurrences are
deconstructors, not constructors -- see limitation 2 above). But
there's no special handling for them in polymorphism.m, so if you try
to use them, it will abort with an internal error.
The changes also includes fixes for a couple of bugs in typechecking
and polymorphism that I discovered while making the above changes,
and an improvement to the error reporting from typecheck.m in one case.
Those changes are listed separately below.
compiler/prog_data.m:
Add a new type `class_constraints', which holds two different
lists of constraints, namely the existentially quantified constraints
and the universally quantified ones.
Add a new field to the parse tree representation of pred and
func declarations to hold a list of the existentially quantified
type variables, and change the `list(class_constraint)' into
`class_constraints' so that we can store existential constraints too.
Add new fields to the `constructor' data type (formerly just a pair)
to hold the existentially quantified type variables and
type class constraints.
compiler/hlds_pred.m:
Add several new fields to the pred_info:
- a list of the existentially quantified type variables;
- a list of the "HeadTypeParams": type variables which
cannot be bound by this predicate (i.e. those whose type_infos
come from this pred's caller or are returned from
other preds called by this one);
- and a list of unsatisfied type class constraints.
Add a predicate pred_info_get_univ_quant_tvars to compute the
universally quantified type variables.
Change the pred constraints field from `list(class_constraint)'
to `class_constraints' so that it can hold existential constraints too.
compiler/hlds_data.m:
Add new fields to hlds_cons_defn to hold the existentially
quantified type variables and type class constraints.
compiler/*.m:
Minor changes to reflect the above-mentioned data structure
changes in prog_data.m, hlds_pred.m, and hlds_data.m.
compiler/prog_io.m:
Add code to parse the new constructs.
Also rewrite the code for parsing purity specifiers,
type quantifiers and type class constraints, using basically
the method suggested by Peter Schachte: treat these as
"declaration attributes", and have parse_decl strip off
all the declaration attributes into a seperate list and
then pass that list to process_decl, which for each different
kind of declaration processes the attributes which are
appropriate for that declaration and then calls check_no_attributes
to ensure that there were no inappropriate attributes.
The purpose of this rewrite was to allow it to handle the new
constructs properly, and to avoid unnecessary code duplication.
compiler/mercury_to_mercury.m:
Add code to pretty-print the new constructs.
compiler/make_hlds.m:
Copy the new fields in the parse tree into the
corresponding new fields in the pred_info.
Add code to check for various misuses of quantifiers.
compiler/hlds_out.m:
Print out the new fields in the pred_info (except the
unsatisfied type class constraints -- if these are non-empty,
post_typecheck.m will print them out in the error message).
When printing out types, pass the AppendVarNums parameter down,
so that HLDS dumps will distinguish between different type
variables that have the same name.
Delete hlds_out__write_constructor, since it was doing exactly
the same thing as mercury__output_ctor.
compiler/typecheck.m:
Lots of changes to handle existential types and existential
type class constraints.
compiler/post_typecheck.m:
When checking for unbound type variables,
use the value of HeadTypeParams from the pred_info.
compiler/type_util.m:
Delete `type_and_constraint_list_matches_exactly', since it was not
used. Add various `apply_variable_renaming_to_*' predicates for
renaming constraints.
compiler/polymorphism.m:
Lots of changes to handle existential types and existential
type class constraints.
Also some changes to make the code more maintainable:
compiler/prog_data.m:
compiler/hlds_goal.m:
compiler/mercury_to_mercury.m:
Put curly braces around the definitions of 'some'/2 and '&'/2 functors
in `:- type' definitions, to avoid them being misinterpreted as
existential type constraints.
compiler/goal_util.m:
compiler/polymorphism.m:
compiler/hlds_pred.m:
compiler/lambda.m:
Include type_infos for existentially quantified type variables
and type_class_infos for existential constraints
in the set of extra variables computed by
goal_util__extra_type_info_vars.
compiler/inlining.m:
Change inlining__do_goal to handle inlining of calls to
existentially typed predicates -- for them, instead of not
binding any type variables at all in the caller, it allows the
call to bind any type variables in the caller except for those
that are universally quantified.
compiler/inlining.m:
compiler/deforest.m:
Call pred_info_get_univ_quant_tvars and pass the
result to inlining__do_inline_goal.
tests/hard_coded/Mmakefile:
tests/hard_coded/existential_types_test.{m,exp}:
tests/hard_coded/typeclasses/Mmakefile:
tests/hard_coded/typeclasses/existential_type_classes.{m,exp}:
Test cases for the use of existential types and
existential type class constraints.
----------
Improve an error message.
compiler/typecheck.m:
Improve error reporting by checking type class constraints for
satisfiability as we go and thus reporting unsatisfiable constraints
as soon as possible, rather than only at the end of the clause.
Previously we already did that for the case of ground constraints,
but they are not the only unsatsfiable constraints: constraints
on head type params (type variables which cannot be bound) are
also unsatisfiable if they can't be eliminated straight away
by context reduction.
tests/invalid/Mmakefile:
tests/invalid/typeclass_test_7.{m,err_exp}:
Regression test for the above change.
----------
Avoid problems where type inference was reporting some
spurious errors for predicates using type classes,
because the check for unsatisfied type class constraints
was being done before the final pass of type inference
had finished.
compiler/hlds_pred.m:
Add new field to the pred_info containing the unproven
type class constraints.
compiler/typecheck.m:
When inferring type class constraints, make sure that before
we save the results back in the pred_info, we restrict the
constraints to the head type variables. Constraints
on other type variables should be treated as
unsatisfied constraints.
Don't check for unsatisfied type class constraints at the
end of each pass; instead, just save the unproven type class
constraints in the pred_info.
compiler/post_typecheck.m:
Check for unsatisfied type class constraints, using
the new field in the pred_info.
tests/hard_coded/typeclasses/Mmakefile:
tests/hard_coded/typeclasses/inference_test_2.{m,exp}:
tests/invalid/Mmakefile:
tests/invalid/typeclass_test_8.{m,err_exp}:
Add regression tests for this change.
----------
Fix a bug with the computation of the non-locals for
predicates with more than one constraint on the same type variable --
it was only including one of the type-class-infos, rather than all of them.
compiler/goal_util.m:
Change `goal_util__extra_nonlocal_typeinfos' so that it gets
passed the TypeClassInfoVarMap and uses this to include all
the appropriate typeclass infos in the extra nonlocals.
compiler/hlds_pred.m:
compiler/lambda.m:
compiler/polymorphism.m:
Pass the TypeClassInfoVarMap to `goal_util__extra_nonlocal_typeinfos'.
tests/hard_coded/typeclasses/Mmakefile:
tests/hard_coded/typeclasses/lambda_multi_constraint_same_tvar.{m,exp}:
Regression test for the above-mentioned bug.
Estimated hours taken: 0.1
tests/invalid/Mmakefile:
Disable typeclass_test_7. It should never have been committed.
(I accidentally committed it on the main branch rather than
the existential_types branch. Doh!)
Estimated hours taken: 1
compiler/typecheck.m:
Improve error reporting by checking type class constraints for
satisfiability as we go and thus reporting unsatisfiable constraints
as soon as possible, rather than only at the end of the clause.
Previously we already did that for the case of ground constraints,
but they are not the only unsatsfiable constraints: constraints
on head type params (type variables which cannot be bound) are
also unsatisfiable if they can't be eliminated straight away
by context reduction.
tests/invalid/Mmakefile:
tests/invalid/typeclass_test_7.m:
tests/invalid/typeclass_test_7.err_exp:
Regression test for the above change.
Estimated hours taken: 0.1
Updated typeclass error messages
tests/invalid/typeclass_test[34].err_exp:
Updated the expected error message to conform to the new format.
Estimated hours taken: 0.25
tests/invalid/Mmakefile:
Allow tests to pass if the output matches either the .err_exp
file or the .err_exp2 file (if any).
tests/invalid/missing_interface_import.err_exp2:
Add an alternative expected output for this test case,
since the output is different depending on whether
or not it gets compiled with --use-subdirs.
Estimated hours taken: 10
Allow modules to be put in source files whose names do not directly match
their the module names. When looking for the source for a module such
as `foo:bar:baz', search for it first in `foo.bar.baz.m', then in `bar.baz.m',
and finally in `baz.m'.
compiler/prog_io.m:
Change prog_io__read_module so that it returns the name of
the module read, as determined by the `:- module' declaration.
Add predicate `check_module_has_expected_name', for checking
that this name matches what was expected.
compiler/modules.m:
Add read_mod_from_file, for reading a module given the file name,
and generated_file_dependencies, for generating the dependencies
of a module given the file name. (As opposed to the module name.)
Change read_mod and read_mod_ignore_errors so that they
search for `.m' files as described above, and return the name
of the source file read.
Also improve the efficiency of read_dependencies slightly:
when reading in `.int' files, there's no need to call
split_into_submodules, because we generate a seperate
`.int' file for each submodule anyway.
compiler/mercury_compile.m:
Change the handling of command-line arguments.
Arguments ending with `.m' are assumed to be file names,
and other arguments are assumed to be module names.
For file names, call read_mod_from_file instead of read_mod.
compiler/handle_options.m:
Change help message to reflect the above change to the semantics
of command-line arguments.
compiler/intermod.m:
compiler/trans_opt.m:
Fix a bug: call prog_io__read_opt_file instead of prog_io__read_module.
doc/user_guide.texi:
Document the above change to the semantics of command-line arguments.
Update the "libraries" chapter to reflect our support for nested
modules.
tests/*/*.m:
tests/*/*.exp:
Fix a few incorrect module names in `:- module' declarations.
Estimated hours taken: 0.1
tests/invalid/typeclass_test_2.m:
tests/invalid/typeclass_test_2.err_exp:
Use more newlines in the test case source so that the test
that the error message is on the correct line number is more
stringent.