Commit Graph

23 Commits

Author SHA1 Message Date
Mark Brown
f552a5fbd4 Remove some debugging code I accidentally committed in my previous
Estimated hours taken: 0
Branches: main

compiler/typeclasses.m:
	Remove some debugging code I accidentally committed in my previous
	change.
2007-09-04 05:32:16 +00:00
Mark Brown
4b41ff219c Fix a bug in the handling of unsatisfiable typeclass constraints.
Estimated hours taken: 5
Branches: main

Fix a bug in the handling of unsatisfiable typeclass constraints.

compiler/typeclasses.m:
	If context reduction fails, continue with the type assign set from the
	start of context reduction rather than a type assign set supplied by
	the caller, which may be missing information that will later be
	required.

compiler/typecheck.m:
	Don't pass the original type assign set.

tests/invalid/Mmakefile:
tests/invalid/typeclass_test_13.err_exp:
tests/invalid/typeclass_test_13.m:
	New test case.

tests/invalid/unsatisfiable_constraint_bug.err_exp:
	Update the expected output, now that we have the information
	required to produce the correct error meswsage.
2007-09-03 11:44:07 +00:00
Zoltan Somogyi
a23873984b In the presence of large amounts of unresolved overloading, the compiler could
Estimated hours taken: 6
Branches: main

In the presence of large amounts of unresolved overloading, the compiler could
consume unbounded amounts of space and time. This diff fixes this problem.

I tried to avoid having this fix lead to a slowdown; in fact, the last three
changes to typecheck_info.m lead to a slight speedup.

compiler/options.m:
doc/user_guide.texi:
	Add a new option, --typecheck-ambiguity-error-limit. This gives the
	number of type assignments that cause the typechecker to stop
	processing further goals. No such facility existed before.

	Add a new option, --typecheck-ambiguity-warn-limit. This gives the
	number of type assignments that cause the typechecker to emit a
	warning. This generalizes the previous hard-coded value in typecheck.m.

	Move the definitions of some existing options to the right set of
	options.

compiler/typecheck_info.m:
	Add the values of the two new options as fields to the typecheck_info,
	since we will want to look them up often.

	Separate out the error_specs concerned with overloading from the other
	error specs, since we want to be able to have an error about excessive
	overloading to overwrite a warning about excessive overloading
	generated earlier.

	Fix a performance bug: the pred_markers were being looked up in the
	pred_info each time they were asked for, even though they were also
	available directly in a field.

	Move the least frequently accessed fields of the typecheck_info
	into a separate substructure, to reduce amount of allocation required.

	Delete the get and set predicates for the most frequently used fields,
	to avoid the overhead of cross-module calls. These fields are now
	accessed via field access functions.

compiler/typecheck.m:
	Don't typecheck goals if the number of type assignments exceeds
	the error limit.

	Conform to the changes in typecheck_info.m.

compiler/typecheck_errors.m:
	Add a function to generate the new error message.

	Conform to the changes in typecheck_info.m.

tests/invalid/ambiguous_overloading_error.{m,err_exp}:
	Add this new test case. It is a copy of the existing test case
	warnings/ambiguous_overloading, but with more overloading. Old
	compilers consume so much memory on it that they eventually run out
	and crash, but the new compiler generates an error message
	and finishes quickly.

tests/invalid/Mmakefile:
	Enable the new test case.

tests/warnings/ambiguous_overloading.exp:
	Update the output of this test case to account for the fact that
	the context of the warning is now that of the goal *after* the point
	at which the number of type assignments exceeds 50, not the goal
	*before* this point.
2007-05-14 08:20:17 +00:00
Mark Brown
2c61c5c128 Fix a bug which could cause non-termination during context
Estimated hours taken: 4
Branches: main

compiler/typeclasses.m:
	Fix a bug which could cause non-termination during context
	reduction.

tests/valid/Mercury.options:
tests/valid/Mmakefile:
tests/valid/time_yaowl.m:
	Test case.
2007-02-27 23:49:57 +00:00
Julien Fischer
b4c3bb1387 Clean up in unused module imports in the Mercury system detected
Estimated hours taken: 3
Branches: main

Clean up in unused module imports in the Mercury system detected
by --warn-unused-imports.

analysis/*.m:
browser/*.m:
deep_profiler/*.m:
compiler/*.m:
library/*.m:
mdbcomp/*.m:
profiler/*.m:
slice/*.m:
	Remove unused module imports.

	Fix some minor departures from our coding standards.

analysis/Mercury.options:
browser/Mercury.options:
deep_profiler/Mercury.options:
compiler/Mercury.options:
library/Mercury.options:
mdbcomp/Mercury.options:
profiler/Mercury.options:
slice/Mercury.options:
	Set --no-warn-unused-imports for those modules that are used as
	packages or otherwise break --warn-unused-imports, e.g. because they
	contain predicates with both foreign and Mercury clauses and some of
	the imports only depend on the latter.
2006-12-01 15:04:40 +00:00
Mark Brown
1c0b5fd8a8 Fix a bug reported by Peter Ross.
Estimated hours taken: 6
Branches: main, release

Fix a bug reported by Peter Ross.

compiler/typeclasses.m:
	When recovering after an unsatisfiable constraint, don't merely
	delete the existing unproven constraints.  Instead construct new
	hlds_constraints from scratch.  This ensures that the invariants
	on it are maintained.

tests/invalid/Mmakefile:
tests/invalid/unsatisfiable_constraint_bug.err_exp:
tests/invalid/unsatisfiable_constraint_bug.m:
	Regression test.
2006-11-21 11:47:49 +00:00
Mark Brown
01a0b8278f Implement superclass reduction in the style of CHRs rather than as a top
Estimated hours taken: 15
Branches: main, release

Implement superclass reduction in the style of CHRs rather than as a top
down search.  This is shorter, simpler, and more consistent with the rest
of the typeclass implementation.  It also removes a few XXXs and fixes a
bug reported by Julien.

compiler/hlds_data.m:
	Add an ancestors field to the hlds_constraint type.  This caches
	all the ancestors of assumed constraints, along with proofs (in the
	form of a sequence of subclass constraints) of how each ancestor is
	derived.

	Update this field whenever new assumed constraints are created, by
	traversing the class hierarchy bottom up.

	Delete the old subclass_details type, which was part of the
	superclass table.

compiler/typeclasses.m:
	Use the cached ancestors to apply the class rules, rather than
	performing a top down search.

compiler/type_util.m:
	Apply substitutions to the ancestors.

compiler/typecheck.m:
compiler/typecheck_info.m:
	Update to account for the additional field.

compiler/*.m:
	Remove the superclass table from the module_info and from the
	interface to context reduction; it is no longer needed.

compiler/hlds_out.m:
	Don't output the superclass table.

tests/valid/Mmakefile:
tests/valid/superclass_bug.m:
	Regression test for the bug that is now fixed.
2006-10-22 09:14:33 +00:00
Peter Ross
84ffc0924d Fix --warn-unused-imports warnings in some of the modules.
Estimated hours taken: 4
Branches: main

library/*.m:
compiler/*.m:
	Fix --warn-unused-imports warnings in some of the modules.
2006-09-27 06:17:09 +00:00
Zoltan Somogyi
f9cac21e3e Get rid of a bunch more ambiguities by renaming predicates, mostly
Estimated hours taken: 8
Branches: main

Get rid of a bunch more ambiguities by renaming predicates, mostly
in polymorphism.m, {abstract,build,ordering}_mode_constraints.m, prog_type.m,
and opt_debug.m in the compiler directory and term_io.m, term.m, parser.m,
and string.m in the library.

In some cases, when the library and the compiler defined the same predicate
with the same code, delete the compiler's copy and give it access to the
library's definition by exporting the relevant predicate (in the undocumented
part of the library module's interface).

NEWS:
	Mention that the names of some library functions have changed.

library/*.m:
compiler/*.m:
mdbcomp/*.m:
browser/*.m:
	Make the changes mentioned above, and conform to them.

test/general/string_test.m:
test/hard_coded/string_strip.m:
test/hard_coded/string_strip.exp:
	Conform to the above changes.
2006-09-20 09:42:28 +00:00
Zoltan Somogyi
6de9f4d1e3 Modify the type and purity check passes to gather up all error messages,
Estimated hours taken: 8
Branches: main

Modify the type and purity check passes to gather up all error messages,
and print them all at once after sorting.

compiler/typecheck.m:
compiler/typeclasses.m:
compiler/post_typecheck.m:
compiler/purity.m:
	Gather up all error messages instead of printing them when generated.
	In some places the gathered list of error specifications allows us
	to eliminate error counts and error flags.

	Eliminate the last occurrences of io.write_* in these modules,
	replacing them with error_specs.

	Change the error messages generated by purity.m to eliminate the
	unnecessary module qualification of the name of the predicate or
	function in which the error occurs.

compiler/typecheck_errors.m:
	Turn the predicates here that used to print error messages
	into functions that just return the error specification.

compiler/mode_errors.m:
	Make a predicate used by post_typecheck.m return an error spec instead
	of writing it out.

compiler/typecheck_info.m:
	Record the list of errors instead of simple a count of the errors
	printed.

compiler/mercury_compile.m:
	Print the error message batches returned by type checking and purity
	checking.

compiler/error_util.m:
	Modify the way we represent severity to allow passes such as
	typechecking to count the number of errors *without* printing
	anything.

compiler/add_pred.m:
compiler/det_report.m:
compiler/make_hlds_warn.m:
compiler/module_qual.m:
	Conform to the change in error_util.m.

compiler/Mercury.options:
	Record the fact that some more compiler modules need the workaround
	for trace goals.

tests/invalid/*err_exp:
tests/warnings/*exp:
	Update the expected output files to conform to the changes above.
	This mosly involves expecting sorted messages without duplicates.
2006-09-12 04:41:52 +00:00
Zoltan Somogyi
5eee81204e A big step towards cleaning up the way we handle errors.
Estimated hours taken: 28
Branches: main

A big step towards cleaning up the way we handle errors. The main changes are

- the provision, in error_util.m, of a mechanism for completely specifying
  everything to do with a single error in one data structure,

- the conversion of typecheck_errors.m from using io.write_string to
  using this new capability,

- the conversion of mode_errors.m and det_report.m from using
  write_error_pieces to using this new capability, and

- consistently using the quoting style `symname'/N instead of `symname/N'
  in error_util and hlds_error_util (previously, error_util used the former
  but hlds_error_util used the latter).

This diff sets up later diffs which will collect all error specifications
in a central place and print them all at once, in order.

compiler/error_util.m:
	The new type error_spec, which completely specifies an error.
	An error_spec may have multiple components with different contexts
	and may have parts which are printed only under certain conditions,
	e.g. a given option being set. Each error_spec has a severity
	and also records which phase found the error.

	The new predicate write_error_spec takes care of updates of the exit
	status for errors and (if --halt-at-warn is set) for warnings. It also
	takes care of setting the flag that calls for the reminder about -E
	at the end.

	This diff also makes it simpler to use the ability to print arbitrary
	output. It adds the ability to include integers in messages directly,
	and the ability to create blank lines. It renames some function symbols
	to avoid ambiguities.

	Move a predicate that only used by typecheck_errors.m to that file.

compiler/hlds_error_util.m:
	Switch to the `symname'/N quoting style for describing predicates and
	procedures.

compiler/prog_util.m:
	Switch to the `symname'/N quoting style for describing
	sym_name_and_arity.

compiler/hlds_module.m:
	Provide a predicate to increment the number of errors not by one,
	but by the number of errors printed by write_error_spec.

	Fix some documentation rot.

compiler/typecheck_errors.m:
	Use write_error_spec instead of io.write_strings to print error
	messages. In several cases, improve the formatting of the messages
	printed.

	Mark a number of places where we don't (yet) update the number of
	errors in the module_info correctly.

	Rename the checkpoint predicate to avoid potential ambiguity with
	similar predicates in e.g. mode_info.

compiler/typecheck_info.m:
	Group the code for writing stuff out together in one bunch. For each
	such predicate, create another that returns a list of format components
	instead of doing I/O directly.

compiler/typecheck.m:
	Move the code for writing inference messages here from
	typecheck_errors.m, since these messages aren't errors.

compiler/mode_errors.m:
compiler/det_report.m:
	Use write_error_spec instead of write_error_pieces. In the case of
	mode_errors.m, this means we now get correct the set of circumstances
	in which we set the flag that calls for the reminder about -E.

compiler/add_pragma.m:
compiler/add_type.m:
	Convert some code that used to use write_error_pieces to print error
	messages to use write_error_spec instead.

compiler/assertion.m:
compiler/hlds_pred.m:
compiler/post_typecheck.m:
	Assertion.m used to contain some code to check for assertions in the
	interface that mention predicates that are not exported. Move most
	of this code to post_typecheck.m (which is where this code used to be
	called from). One small part, which is a test for a particular property
	of import_statuses, is moved to hlds_pred.m to be with all the other
	similar tests of import_statuses.

compiler/prog_util.m:
	Change unqualify_name from a predicate to a function.

compiler/pred_table.m:
compiler/hlds_out.m:
	Avoid some ambiguities by adding a suffix to the names of some
	predicates.

compiler/*.m:
	Conform to the changes above.

library/list.m:
	Add a function that was previously present (with different names)
	in two compiler modules.

tests/hard_coded/allow_stubs.exp:
	Update the format of the expected exception.

tests/invalid/errors2.err_exp2:
	Remove this file. As far as I can tell, it was never the correct
	expected output on the main branch. (It originated on the alias branch
	way back in the mists of time.)

tests/invalid/*.err_exp:
tests/invalid/purity/*.err_exp:
tests/warnings/*.exp:
	Update the format of the expected error messages.

tests/recompilation/*.err_exp.2:
	Update the format of the expected messages about what was modified.
2006-09-07 05:51:48 +00:00
Julien Fischer
aeeedd2c13 Standardize formatting of comments at the beginning of modules.
compiler/*.m:
	Standardize formatting of comments at the beginning of modules.
2006-07-31 08:32:11 +00:00
Mark Brown
a46e9179d3 Fix a bug reported by Peter Ross. The problem was that the ancestors of
Estimated hours taken: 8
Branches: main, release

Fix a bug reported by Peter Ross.  The problem was that the ancestors of
assumed constraints were not being used to find opportunities for
improvement, which led to some potential improvements being missed.

compiler/hlds_data.m:
	Include assumed constraints (and their ancestors) in the set of
	redundant constraints, as these can also play a part in improvements
	even though they cannot themselves be improved.

compiler/typeclasses.m:
	When applying the class improvement rules, don't try to match on
	assumed constraints.  These are now contained in the redundant
	constraints, which we already process.

tests/hard_coded/typeclasses/Mmakefile:
tests/hard_coded/typeclasses/fundeps_5.exp:
tests/hard_coded/typeclasses/fundeps_5.m:
	A regression test.
2006-05-31 16:00:40 +00:00
Julien Fischer
459847a064 Move the univ, maybe, pair and unit types from std_util into their own
Estimated hours taken: 18
Branches: main

Move the univ, maybe, pair and unit types from std_util into their own
modules.  std_util still contains the general purpose higher-order programming
constructs.

library/std_util.m:
	Move univ, maybe, pair and unit (plus any other related types
	and procedures) into their own modules.

library/maybe.m:
	New module.  This contains the maybe and maybe_error types and
	the associated procedures.

library/pair.m:
	New module.  This contains the pair type and associated procedures.

library/unit.m:
	New module. This contains the types unit/0 and unit/1.

library/univ.m:
	New module. This contains the univ type and associated procedures.

library/library.m:
	Add the new modules.

library/private_builtin.m:
	Update the declaration of the type_ctor_info struct for univ.

runtime/mercury.h:
	Update the declaration for the type_ctor_info struct for univ.

runtime/mercury_mcpp.h:
runtime/mercury_hlc_types.h:
	Update the definition of MR_Univ.

runtime/mercury_init.h:
	Fix a comment: ML_type_name is now exported from type_desc.m.

compiler/mlds_to_il.m:
	Update the the name of the module that defines univs (which are
	handled specially by the il code generator.)

library/*.m:
compiler/*.m:
browser/*.m:
mdbcomp/*.m:
profiler/*.m:
deep_profiler/*.m:
	Conform to the above changes.  Import the new modules where they
	are needed; don't import std_util where it isn't needed.

	Fix formatting in lots of modules.  Delete duplicate module
	imports.

tests/*:
	Update the test suite to confrom to the above changes.
2006-03-29 08:09:58 +00:00
Zoltan Somogyi
be5b71861b Convert almost all the compiler modules to use . instead of __ as
Estimated hours taken: 6
Branches: main

compiler/*.m:
	Convert almost all the compiler modules to use . instead of __ as
	the module qualifier.

	In some cases, change the names of predicates and types to make them
	meaningful without the module qualifier. In particular, most of the
	types that used to be referred to with an "mlds__" prefix have been
	changed to have a "mlds_" prefix instead of changing the prefix to
	"mlds.".

	There are no algorithmic changes.
2006-03-17 01:40:46 +00:00
Julien Fischer
5f589e98fb Various cleanups for the modules in the compiler directory.
Estimated hours taken: 4
Branches: main

Various cleanups for the modules in the compiler directory.  The are
no changes to algorithms except the replacement of some if-then-elses
that would naturally be switches with switches and the replacement of
most of the calls to error/1.

compiler/*.m:
	Convert calls to error/1 to calls to unexpected/2 or sorry/2 as
	appropriate throughout most or the compiler.

	Fix inaccurate assertion failure messages, e.g. identifying the
	assertion failure as taking place in the wrong module.

	Add :- end_module declarations.

	Fix formatting problems and bring the positioning of comments
	into line with our current coding standards.

	Fix some overlong lines.

	Convert some more modules to 4-space indentation.  Fix some spots
	where previous conversions to 4-space indentation have stuffed
	the formatting of the code up.

	Fix a bunch of typos in comments.

	Use state variables in more places; use library predicates
	from the sv* modules where appropriate.

	Delete unnecessary and duplicate module imports.

	Misc. other small cleanups.
2005-11-17 15:57:34 +00:00
Zoltan Somogyi
21685c9e22 Improve the error messages generated for determinism errors involving committed
Estimated hours taken: 6
Branches: main

Improve the error messages generated for determinism errors involving committed
choice contexts. Previously, we printed a message to the effect that e.g.
a cc pred is called in context that requires all solutions, but we didn't say
*why* the context requires all solutions. We now keep track of all the goals
to the right that could fail, since it is these goals that may reject the first
solution of a committed choice goal.

The motivation for this diff was the fact that I found that locating the
failing goal can be very difficult if the conjunction to the right is
a couple of hundred lines long. This would have been a nontrivial problem,
since (a) unifications involving values of user-defined types are committed
choice goals, and (b) we can expect uses of user-defined types to increase.

compiler/det_analysis.m:
	Keep track of goals to the right of the current goal that could fail,
	and include them in the error representation if required.

compiler/det_report.m:
	Include the list of failing goals to the right in the representations
	of determinism errors involving committed committed choice goals.

	Convert the last part of this module that wasn't using error_util
	to use error_util. Make most parts of this module just construct
	error message specifications; print those specifications (using
	error_util) in only a few places.

compiler/hlds_out.m:
	Add a function for use by the new code in det_report.m.

compiler/error_util.m:
	Add a function for use by the new code in det_report.m.

compiler/error_util.m:
compiler/compiler_util.m:
	Error_util is still changing reasonably often, and yet it is
	included in lots of modules, most of which need only a few simple
	non-parse-tree-related predicates from it (e.g. unexpected).
	Move those predicates to a new module, compiler_util.m. This also
	eliminates some undesirable dependencies from libs to parse_tree.

compiler/libs.m:
	Include compiler_util.m.

compiler/notes/compiler_design.html:
	Document compiler_util.m, and fix the documentation of some other
	modules.

compiler/*.m:
	Import compiler_util instead of or in addition to error_util.
	To make this easier, consistently use . instead of __ for module
	qualifying module names.

tests/invalid/det_errors_cc.{m,err_exp}:
	Add this new test case to test the error messages for cc contexts.

tests/invalid/det_errors_deet.{m,err_exp}:
	Add this new test case to test the error messages for unifications
	inside function symbols.

tests/invalid/Mmakefile:
	Add the new test cases.

tests/invalid/det_errors.err_exp:
tests/invalid/magicbox.err_exp:
	Change the expected output to conform to the change in det_report.m,
	which is now more consistent.
2005-11-04 03:41:09 +00:00
Zoltan Somogyi
b2012c0c0e Rename the types 'type', 'inst' and 'mode' to 'mer_type', 'mer_inst'
Estimated hours taken: 8
Branches: main

compiler/*.m:
	Rename the types 'type', 'inst' and 'mode' to 'mer_type', 'mer_inst'
	and 'mer_mode'. This is to avoid the need to parenthesize these type
	names in some contexts, and to prepare for the possibility of a parser
	that considers those words to be reserved words.

	Rename some other uses of those names (e.g. as item types in
	recompilation.m).

	Delete some redundant synonyms (prog_type, mercury_type) for mer_type.

	Change some type names (e.g. mlds__type) and predicate names (e.g.
	deforest__goal) to make them unique even without module qualification.

	Rename the function symbols (e.g. pure, &) that need to be renamed
	to avoid the need to parenthesize them. Make their replacement names
	more expressive.

	Convert some more modules to four space indentation.

	Avoid excessively long lines, such as those resulting from the
	automatic substitution of 'mer_type' for 'type'.
2005-10-24 04:14:34 +00:00
Zoltan Somogyi
d7554de953 Convert a bunch more modules to four-space indentation.
Estimated hours taken: 5
Branches: main

browser/*.m:
compiler/*.m:
mdbcomp/*.m:
	Convert a bunch more modules to four-space indentation.
2005-10-19 05:39:08 +00:00
Zoltan Somogyi
b54ab42d70 A simple tool for performing substitutions on the source files of the
Estimated hours taken: 0.5
Branches: main

tools/subst:
	A simple tool for performing substitutions on the source files of the
	compiler.

compiler/*.m:
	Change the names of the get predicates operating on module_infos to
	include "get" in the name, for uniformity. This was done mostly by
	the following sed script, with some manual cleanup afterwards to reduce
	excessive line lengths.

s/module_info_types/module_info_get_type_table/
s/module_info_set_types/module_info_set_type_table/
s/module_info_insts/module_info_get_inst_table/
s/module_info_set_insts/module_info_set_inst_table/
s/module_info_modes/module_info_get_mode_table/
s/module_info_set_modes/module_info_set_mode_table/
s/module_info_ctors/module_info_get_cons_table/
s/module_info_set_ctors/module_info_set_cons_table/
s/module_info_classes/module_info_get_class_table/
s/module_info_set_classes/module_info_set_class_table/
s/module_info_instances/module_info_get_instance_table/
s/module_info_set_instances/module_info_set_instance_table/
s/module_info_superclasses/module_info_get_superclass_table/
s/module_info_set_superclasses/module_info_set_superclass_table/
s/module_info_assertion_table/module_info_get_assertion_table/
s/module_info_exclusive_table/module_info_get_exclusive_table/
s/module_info_ctor_field_table/module_info_get_ctor_field_table/
s/module_info_name/module_info_get_name/
s/module_info_globals/module_info_get_globals/
s/module_info_contains_foreign_types/module_info_get_contains_foreign_types/
s/module_info_num_errors/module_info_get_num_errors/
s/module_info_type_ctor_gen_infos/module_info_get_type_ctor_gen_infos/
s/module_info_stratified_preds/module_info_get_stratified_preds/
s/module_info_unused_arg_info/module_info_get_unused_arg_info/
s/module_info_exception_info/module_info_get_exception_info/
s/module_info_type_spec_info/module_info_get_type_spec_info/
s/module_info_no_tag_types/module_info_get_no_tag_types/
s/module_info_analysis_info/module_info_get_analysis_info/
s/module_info_aditi_top_down_procs/module_info_get_aditi_top_down_procs/
2005-09-30 08:08:49 +00:00
Mark Brown
3fc6b3f128 Change the representation of types in the compiler.
Estimated hours taken: 30
Branches: main

Change the representation of types in the compiler.

We also add some support for handling kinds, which will be used later when we
have a kind system.  There are a number of places where kinds are not yet
handled correctly -- we assume that all kinds will be `star'.  Each of these
locations is flagged with a comment that contains "XXX kind inference:".


compiler/prog_data.m:
	Implement the new version of type (type).

	Change the definition of type_param to be a variable instead of a
	term, since all parameters must be variables anyway.

	Implement versions of varset.merge_* which work with tvarsets and
	produce renamings instead of substitutions.  Renamings are more
	convenient than substitutions because we don't need to know the
	kinds of type variables in order to build the renaming, and in any
	case the substitutions shouldn't have anything other than variables
	in the range so renamings will be more efficient and safe.

	Define the type of kinds, and provide a couple of utility predicates
	to operate on them.

compiler/prog_io.m:
	Parse type definition heads as a sym_name and list of type_params,
	rather than a functor.  Handle this change in other predicates.

	Allow parse errors to be returned by get_with_type/3, and handle
	these errors.

	Remove parse_type/2.  This predicate didn't do any processing, it
	just forwarded handling to convert_type/2.

compiler/prog_io_typeclass.m:
	Change type_is_functor_and_vars to handle the new representation
	of types.  In doing so, we retain the old behaviour that pure
	predicates pass this test, but no other pred or func types.  This
	behaviour is arguably incorrect, but there is little point changing
	the behaviour at the moment.  Instead we should remove these kind of
	restrictions entirely, but that should be done later.

compiler/prog_io_util.m:
	Provide predicates to both parse and unparse types.  We need to
	unparse types before printing them out, since we do a lot of special
	case handling when printing out terms and we don't want to duplicate
	this functionality for types.

compiler/module_qual.m:
	Remove report_invalid_type.  We now report ill-formed types during
	parsing.

compiler/superhomogeneous.m:
	Handle errors from the parsing of type expressions.

compiler/prog_out.m:
	Provide a predicate to convert builtin_types to their string names,
	and vice-versa.

compiler/prog_type.m:
	Add a bunch of simple tests to use on types which may have kind
	annotations present.  In such cases, types do not have a canonical
	representation so the simple handling of these tests is not what we
	want.  (Note that these are only required in early phases.  The kind
	annotations -- when they are implemented -- will be removed before
	type checking.)

	Consistently handle the application of renamings, substitutions and
	recursive substitutions to various data structures.

compiler/mercury_to_mercury.m:
	Implement mercury_output_type, mercury_format_type and
	mercury_type_to_string.  These convert the type to a term before
	formatting -- the reason for this is so that appropriate parentheses
	are used when formatting operators.  This results in some slight
	changes to error messages, which are reflected in changes to the
	expected output files in the tests.

	Remove the old version of mercury_type_to_string.

	Change the argument ordering of mercury_format_var to be consistent
	with mercury_format_type.  (Other predicates in this module should
	probably be changed in a similar way, since this argument ordering
	is more amenable to higher-order programming.  But that can be left
	for another change.)

compiler/type_util.m:
	Implement type unification.  The behaviour is much the same as the
	previous behaviour, except that we now handle apply/N types properly,
	and we also allow for kind annotations.

	Implement an occurs check for types.

	Remove the example definition of replace_eqv_type.  It isn't used and
	would no longer work anyway even if it would have worked before.

	Add a tvar_kind_map field to ctor_defn.

	The functions type_info_type and type_ctor_info_type now return
	types with `void' as their argument, rather than the type that the
	type_info or type_ctor_info was for.

	Remove type_util.real_vars/2, since it no longer does anything
	different from prog_type.vars/2.

	Remove the commented out implementation of type_to_ctor_and_args/3.
	Its implementation is in prog_type.m, and has changed significantly
	in any case.

compiler/add_clause.m:
	Move parse_purity_annotation/3 to prog_io_util.m.

compiler/check_typeclass.m:
	Remove apply_substitution_to_var_list/3, since we now have predicates
	in prog_type.m to handle such things.

compiler/continuation_info.m:
compiler/trace.m:
	Use prog_type.vars/2 instead of type_util.real_vars/2.  The two
	predicates have the same meaning now since type_infos don't contain
	any type variables.

compiler/hlds_data.m:
	Add tvar_kind_map fields to hlds_type_defn and hlds_class_defn.

compiler/hlds_pred.m:
	Add a tvar_kind_map field to pred_info.

compiler/polymorphism.m:
	Add a tvar_kind_map field to poly_info.

	Remove unify_corresponding_types, which is no longer used.

compiler/hlds_out.m:
	Use mercury_output_type/5 instead of term_io__write_term/4 and
	mercury_output_term/5.

compiler/post_typecheck.m:
	Build the void substitution directly rather than building intermediate
	lists.

compiler/recompilation.version.m:
	Use term__list_subsumes instead of type_list_subsumes, which now
	operates only on types.  This follows up on what was suggested in
	an XXX comment.

compiler/typecheck_errors.m:
	Use unparse_type/2 to format error messages.

compiler/typecheck_info.m:
	Don't export write_type_with_bindings/5.  It is no longer used
	outside of this module.

compiler/*.m:
	Conform to the above changes.

library/rtti_implementation.m:
	Fix a syntax error that went undetected in our previous
	implementation, and amazingly enough was compiled correctly anyway.

library/term.m:
	Move the versions of term__unify, term__unify_list and
	term__list_subsumes that were implemented specifically for types
	to here.  The version of term_unify that takes a list of bound
	variables (i.e., variables that should not be bound any further)
	is used by the subsumption check, which in turn is used by
	recompilation.version.m.

tests/invalid/kind.err_exp:
tests/invalid/tc_err1.err_exp:
tests/invalid/tc_err2.err_exp:
tests/misc_tests/pretty_print_test.exp:
	Update the expected output of these tests to match what we now do.
2005-09-12 05:25:01 +00:00
Mark Brown
5d0ba8a866 Use the constraint parameters as "head type parameters" when calling
Estimated hours taken: 3
Branches: main

compiler/typeclasses.m:
	Use the constraint parameters as "head type parameters" when calling
	'eliminate_constraint_by_class_rules'.  This fixes a bug whereby
	constraints were being reduced even when unsatisfiable, which would
	result in polymorphism generating code that was not mode correct.

	Also move a call to 'apply_rec_subst_to_constraints' one step up in
	the call graph.  This puts both calls to this predicate at the same
	level, and thereby makes the code easier to understand.

	Only call 'apply_rec_subst_to_constraints' on the second occasion
	if the bindings have actually changed since the first call.  This
	is just for the purposes of optimisation.

tests/invalid/Mmakefile:
tests/invalid/unsatisfiable_super.err_exp:
tests/invalid/unsatisfiable_super.m:
	New test case to test the bug fix.
2005-04-28 07:25:02 +00:00
Mark Brown
cb2c3ec8bf Split typecheck.m into smaller modules.
Estimated hours taken: 3
Branches: main

Split typecheck.m into smaller modules.

compiler/typecheck.m:
	The main typechecking pass.

compiler/typecheck_errors.m:
	New module.  Error messages and debugging messages.

compiler/typecheck_info.m:
	New module.  The typecheck_info and type_assign data structures, plus
	some basic predicates.

compiler/typeclasses.m:
	New module.  The context reduction and improvement rules.

compiler/check_hlds.m:
	Register the new modules.

compiler/check_typeclass.m:
	Call typeclasses instead of typecheck to do context reduction.

compiler/prog_type.m:
	Move strip_builtin_qualifiers_from_type(_list) to here.

compiler/hlds_data.m:
	Define restrict_list_elements here instead of in typecheck.m and
	check_typeclass.m.
2005-04-23 06:29:48 +00:00