Commit Graph

79 Commits

Author SHA1 Message Date
Fergus Henderson
861e1caf91 Allow tests to pass if the output matches either the .err_exp
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.
1998-06-06 11:09:58 +00:00
Fergus Henderson
eae7eec887 Allow modules to be put in source files whose names do not directly match
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.
1998-05-29 08:57:42 +00:00
Fergus Henderson
469fddf17c Use more newlines in the test case source so that the test
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.
1998-05-18 08:54:49 +00:00
Zoltan Somogyi
564d358da3 Avoid about half of the slow "mmake realclean"s required by a bootcheck.
Estimated hours taken: 0.5

Avoid about half of the slow "mmake realclean"s required by a bootcheck.

tests/*/runtests:
	Concentrate all the actions performed before the test and after
	a successful tests (both of which involve an "mmake realclean")
	into two scripts, tests/{startup,shutdown}.

tests/shutdown:
	Clean up the directory, and touch the file CLEAN.

tests/startup:
	If the file CLEAN exists and is the most recent file in the directory,
	consider the directory clean to beging with. Otherwise, run mmake
	realclean.
1998-05-13 04:06:38 +00:00
Zoltan Somogyi
cd31eecf88 When reporting the results, print the options that controlled
Estimated hours taken: 0.2

tests/runtests:
tests/*/runtests:
	When reporting the results, print the options that controlled
	the tests, so you don't have to search for them.

tests/*/runtests:
	Clean up the directory if the tests are successful, in order
	to reduce disk space usage.
1998-04-23 09:28:39 +00:00
Fergus Henderson
7f261f912b A few more improvements to type class checking.
Estimated hours taken: 4

A few more improvements to type class checking.

compiler/typecheck.m:
	Ensure that we run a final pass of context reduction at the
	end of typechecking each predicate (or function).

	Change the way perform_context_reduction recovers after errors
	to avoid reporting the same error more than once
	(e.g. for tests/invalid/typeclass_test_2.m).

	Simplify the code to check for and report unsatisfied
	type class constraints.

	Change write_type_assign so that it prints out the
	type class constraints as well as the variable types.

tests/invalid/typeclass_test_*.err_exp:
	Add a full stop that was missing at the end of
	the "unsatisfied typeclass constraint" error message.
1998-04-09 18:33:13 +00:00
Fergus Henderson
40f7fad627 Fix some code rot in the rules for `make clean';
Estimated hours taken: 0.5

Makefile:
tests/valid/Mmakefile:
tests/invalid/Mmakefile:
	Fix some code rot in the rules for `make clean';
	amoung other things, change them so that they
	handle `--use-subdirs' correctly.
1998-04-09 03:59:12 +00:00
Fergus Henderson
570b4baa76 Invoke `mmake depend'.
Estimated hours taken: 0.25

tests/invalid/runtests:
	Invoke `mmake depend'.

tests/term/runtests:
	Delete the `set -x', which was just there for debugging,
	since it just makes the output harder to read.
1998-03-20 04:25:15 +00:00
Fergus Henderson
f4caf49a15 Fix a limitation of the current nested module support:
Estimated hours taken: 4

Fix a limitation of the current nested module support:
ensure that we check for attempts to import inaccessible modules.

compiler/modules.m:
	Check for attempts to import inaccessible modules
	(modules whose parent has not been imported,
	or for which there is no `include_module'
	declaration in the parent's interface).

compiler/intermod.m:
	Modify the way we import `.opt' files.  The previous method
	temporarily set the items field of the module_imports
	structure to [], but check_module_accessibility relies
	on the assumption that the items field contains the
	items for all modules previously read in.

tests/invalid/Mmakefile:
tests/invalid/test_nested.m:
tests/invalid/test_nested.err_exp:
tests/invalid/parent.m:
tests/invalid/parent.private_child.m:
tests/invalid/parent.public_child.m:
tests/invalid/parent.undeclared_child.m:
tests/invalid/parent.undeclared_child.err_exp:
tests/invalid/parent2.m:
tests/invalid/parent2.child.m:
	Add some tests for the above change.

doc/reference_manual.texi:
	Update the "bugs and limitations" sub-section of the modules
	chapter to reflect the new status quo.
1998-03-18 17:31:08 +00:00
Fergus Henderson
f3aa40d62c Add a test case for an old bug: the case where
Estimated hours taken: 0.25

tests/invalid/Mmakefile:
tests/invalid/type_inf_loop.m:
tests/invalid/type_inf_loop.err_exp:
	Add a test case for an old bug: the case where
	type inference leads to an infinite loop.
1998-03-18 10:22:14 +00:00
Zoltan Somogyi
b42633fb71 Enable the test case for incomplete predmode declarations.
Estimated hours taken: 0.1

tests/invalid/Mmakefile:
	Enable the test case for incomplete predmode declarations.

tests/invalid/predmode.err_exp:
	Update the expected message.
1998-03-04 04:37:32 +00:00
Fergus Henderson
11d8161692 Add support for nested modules.
Estimated hours taken: 50

Add support for nested modules.

- module names may themselves be module-qualified
- modules may contain `:- include_module' declarations
  which name sub-modules
- a sub-module has access to all the declarations in the
  parent module (including its implementation section).

This support is not yet complete; see the BUGS and LIMITATIONS below.

LIMITATIONS
- source file names must match module names
	(just as they did previously)
- mmc doesn't allow path names on the command line any more
	(e.g. `mmc --make-int ../library/foo.m').
- import_module declarations must use the fully-qualified module name
- module qualifiers must use the fully-qualified module name
- no support for root-qualified module names
	(e.g. `:parent:child' instead of `parent:child').
- modules may not be physically nested (only logical nesting, via
  `include_module').

BUGS
- doesn't check that the parent module is imported/used before allowing
	import/use of its sub-modules.
- doesn't check that there is an include_module declaration in the
	parent for each module claiming to be a child of that parent
- privacy of private modules is not enforced

-------------------

NEWS:
	Mention that we support nested modules.

library/ops.m:
library/nc_builtin.nl:
library/sp_builtin.nl:
compiler/mercury_to_mercury.m:
	Add `include_module' as a new prefix operator.
	Change the associativity of `:' from xfy to yfx
	(since this made parsing module qualifiers slightly easier).

compiler/prog_data.m:
	Add new `include_module' declaration.
	Change the `module_name' and `module_specifier' types
	from strings to sym_names, so that module names can
	themselves be module qualified.

compiler/modules.m:
	Add predicates module_name_to_file_name/2 and
	file_name_to_module_name/2.
	Lots of changes to handle parent module dependencies,
	to create parent interface (`.int0') files, to read them in,
	to output correct dependencies information for them to the
	`.d' and `.dep' files, etc.
	Rewrite a lot of the code to improve the readability
	(add comments, use subroutines, better variable names).
	Also fix a couple of bugs:
	- generate_dependencies was using the transitive implementation
	  dependencies rather than the transitive interface dependencies
	  to compute the `.int3' dependencies when writing `.d' files
	  (this bug was introduced during crs's changes to support
	  `.trans_opt' files)
	- when creating the `.int' file, it was reading in the
	  interfaces for modules imported in the implementation section,
	  not just those in the interface section.
	  This meant that the compiler missed a lot of errors.

library/graph.m:
library/lexer.m:
library/term.m:
library/term_io.m:
library/varset.m:
compiler/*.m:
	Add `:- import_module' declarations to the interface needed
	by declarations in the interface.  (The previous version
	of the compiler did not detect these missing interface imports,
	due to the above-mentioned bug in modules.m.)

compiler/mercury_compile.m:
compiler/intermod.m:
	Change mercury_compile__maybe_grab_optfiles and
	intermod__grab_optfiles so that they grab the opt files for
	parent modules as well as the ones for imported modules.

compiler/mercury_compile.m:
	Minor changes to handle parent module dependencies.
	(Also improve the wording of the warning about trans-opt
	dependencies.)

compiler/make_hlds.m:
compiler/module_qual.m:
	Ignore `:- include_module' declarations.

compiler/module_qual.m:
	A couple of small changes to handle nested module names.

compiler/prog_out.m:
compiler/prog_util.m:
	Add new predicates string_to_sym_name/3 (prog_util.m) and
	sym_name_to_string/{2,3} (prog_out.m).

compiler/*.m:
	Replace many occurrences of `string' with `module_name'.
	Change code that prints out module names or converts
	them to strings or filenames to handle the fact that
	module names are now sym_names intead of strings.
	Also change a few places (e.g. in intermod.m, hlds_module.m)
	where the code assumed that any qualified symbol was
	fully-qualified.

compiler/prog_io.m:
compiler/prog_io_goal.m:
	Move sym_name_and_args/3, parse_qualified_term/4 and
	parse_qualified_term/5 preds from prog_io_goal.m to prog_io.m,
	since they are very similar to the parse_symbol_name/2 predicate
	already in prog_io.m.  Rewrite these predicates, both
	to improve maintainability, and to handle the newly
	allowed syntax (module-qualified module names).
	Rename parse_qualified_term/5 as `parse_implicit_qualified_term'.

compiler/prog_io.m:
	Rewrite the handling of `:- module' and `:- end_module'
	declarations, so that it can handle nested modules.
	Add code to parse `include_module' declarations.

compiler/prog_util.m:
compiler/*.m:
	Add new predicates mercury_public_builtin_module/1 and
	mercury_private_builtin_module/1 in prog_util.m.
	Change most of the hard-coded occurrences of "mercury_builtin"
	to call mercury_private_builtin_module/1 or
	mercury_public_builtin_module/1 or both.

compiler/llds_out.m:
	Add llds_out__sym_name_mangle/2, for mangling module names.

compiler/special_pred.m:
compiler/mode_util.m:
compiler/clause_to_proc.m:
compiler/prog_io_goal.m:
compiler/lambda.m:
compiler/polymorphism.m:
	Move the predicates in_mode/1, out_mode/1, and uo_mode/1
	from special_pred.m to mode_util.m, and change various
	hard-coded definitions to instead call these predicates.

compiler/polymorphism.m:
	Ensure that the type names `type_info' and `typeclass_info' are
	module-qualified in the generated code.  This avoids a problem
	where the code generated by polymorphism.m was not considered
	type-correct, due to the type `type_info' not matching
	`mercury_builtin:type_info'.

compiler/check_typeclass.m:
	Simplify the code for check_instance_pred and
	get_matching_instance_pred_ids.

compiler/mercury_compile.m:
compiler/modules.m:
	Disallow directory names in command-line arguments.

compiler/options.m:
compiler/handle_options.m:
compiler/mercury_compile.m:
compiler/modules.m:
	Add a `--make-private-interface' option.
	The private interface file `<module>.int0' contains
	all the declarations in the module; it is used for
	compiling sub-modules.

scripts/Mmake.rules:
scripts/Mmake.vars.in:
	Add support for creating `.int0' and `.date0' files
	by invoking mmc with `--make-private-interface'.

doc/user_guide.texi:
	Document `--make-private-interface' and the `.int0'
	and `.date0' file extensions.

doc/reference_manual.texi:
	Document nested modules.

util/mdemangle.c:
profiler/demangle.m:
	Demangle names with multiple module qualifiers.

tests/general/Mmakefile:
tests/general/string_format_test.m:
tests/general/string_format_test.exp:
tests/general/string__format_test.m:
tests/general/string__format_test.exp:
tests/general/.cvsignore:
	Change the `:- module string__format_test' declaration in
	`string__format_test.m' to `:- module string_format_test',
	because with the original declaration the `__' was taken
	as a module qualifier, which lead to an error message.
	Hence rename the file accordingly, to avoid the warning
	about file name not matching module name.

tests/invalid/Mmakefile:
tests/invalid/missing_interface_import.m:
tests/invalid/missing_interface_import.err_exp:
	Regression test to check that the compiler reports
	errors for missing `import_module' in the interface section.

tests/invalid/*.err_exp:
tests/warnings/unused_args_test.exp:
tests/warnings/unused_import.exp:
	Update the expected diagnostics output for the test cases to
	reflect a few minor changes to the warning messages.

tests/hard_coded/Mmakefile:
tests/hard_coded/parent.m:
tests/hard_coded/parent.child.m:
tests/hard_coded/parent.exp:
tests/hard_coded/parent2.m:
tests/hard_coded/parent2.child.m:
tests/hard_coded/parent2.exp:
	Two simple tests case for the use of nested modules with
	separate compilation.
1998-03-03 17:48:14 +00:00
Andrew Bromage
046f2afecb Fix a semantic hole. Previously, unique variables could be used
Estimated hours taken: 6

Fix a semantic hole.  Previously, unique variables could be used
as non-local variables inside a lambda goal and shared within that
lambda.  This fixes the problem by requiring that all non-local
vars to a lambda must be ground-shared.

compiler/modecheck_unify.m:
	Changes detailed above.

compiler/mode_errors.m:
	Add a new kind of mode error, mode_error_non_local_lambda_var.
	One small change to find_important_errors/3 to ensure that this
	error will be reported if the lambda is an implicit call argument
	unification.

compiler/inst_util.m:
	Export make_shared_inst_list/4 for use by modecheck_unify.m.

compiler/instmap.m:
	New predicate: instmap__set_vars/4, which sets multiple vars
	in an instmap.

tests/invalid/bind_var_errors.m:
tests/invalid/bind_var_errors.err_exp:
	Regression test.
1998-02-13 10:12:35 +00:00
David Jeffery
e0184c7df7 Enable the typeclass_test_3 test case.
Estimated hours taken: 0.25

Enable the typeclass_test_3 test case.

invalid/Mmakefile:
	Enable the typeclass_test_3 test.
invalid/typeclass_test_3.m:
	Fix the module name.
invalid/Mmakefile:
	Fix up the expected output.
1998-02-03 08:01:59 +00:00
Zoltan Somogyi
c4e5614e7a Add the now expected lines about clauses in the interface.
Estimated hours taken: 0.01

tests/invalid/any_mode.err_exp:
	Add the now expected lines about clauses in the interface.
1998-02-02 06:11:29 +00:00
Fergus Henderson
c9bd1fa4cd Update to include the new warnings about clauses and pragmas in
Estimated hours taken: 0.25

tests/invalid/pragma_c_code_and_clauses1.err_exp:
tests/invalid/pragma_c_code_and_clauses2.err_exp:
	Update to include the new warnings about clauses and pragmas in
	module interfaces.
1998-02-02 03:01:12 +00:00
Fergus Henderson
e01643b8ef Fix some mistakes in the expected output for these tests
Estimated hours taken: 0.25

tests/typeclass_test_1.err_exp:
tests/typeclass_test_2.err_exp:
tests/typeclass_test_3.err_exp:
	Fix some mistakes in the expected output for these tests
	(Originally I called them `test_typeclass_*', later I renamed
	them as `typeclass_test_*', but forgot to update the expected
	output to reflect this.)
1998-02-02 02:55:58 +00:00
Andrew Bromage
513132f8a8 Better error reporting for variables bound in illegal places.
Estimated hours taken: 2

Better error reporting for variables bound in illegal places.

compiler/mode_info.m:
	Add a var_lock_reason, specifying the reason why a variable
	is locked during mode checking.

compiler/modecheck_unify.m:
compiler/modes.m:
compiler/unique_modes.m:
	Specify the reason when locking some variables.

compiler/mode_errors.m:
	When reporting var locking errors, give the reason why the
	var was locked.

tests/invalid/Mmakefile:
tests/invalid/bind_var_errors.err_exp:
tests/invalid/bind_var_errors.m:
	Regression tests for the above changes.
1998-01-30 06:13:35 +00:00
Fergus Henderson
40dcaf4f4f For calls to class methods, if the particular class instance is
Estimated hours taken: 3 (plus 1 from dgj)

compiler/polymorphism.m:
	For calls to class methods, if the particular class instance is
	known at the call site, then specialize the code by generating
	a direct call to the method for that instance.

tests/invalid/Mmakefile:
tests/invalid/typeclass_test_{1,2,3,4}.m:
tests/invalid/typeclass_test_{1,2,3,4}.err_exp:
tests/hard_coded/Mmakefile:
tests/hard_coded/typeclass_test_{5,6}.m:
tests/hard_coded/typeclass_test_{5,6}.exp:
	Some test cases for type classes, including one for the above change.
1998-01-29 08:39:56 +00:00
Fergus Henderson
968b084fbe Delete all the obsolete code using magic numbers (e.g. 10000)
Estimated hours taken: 0.75

compiler/bytecode.m:
compiler/code_util.m:
compiler/const_prop.m:
compiler/hlds_out.m:
compiler/intermod.m:
compiler/llds_out.m:
compiler/make_hlds.m:
compiler/mercury_to_c.m:
compiler/modes.m:
compiler/special_pred.m:
compiler/term_errors.m:
compiler/trace.m:
	Delete all the obsolete code using magic numbers (e.g. 10000)
	for proc_ids.  This old hack, whereby make_hlds.m assigned
	mode numbers based on the priority given to the determinism of
	each mode, is not needed anymore.  It is no longer needed
	because modecheck_call.m now chooses the mode that is the best
	fit (based on a variety of factors) rather than just picking
	the first allowable mode.

tests/invalid/duplicate_modes.err_exp:
	The output for this test changed, in insignificant ways:
	the order in which it reported the duplicates modes changed,
	because the mode numbers had changed.
1998-01-24 05:44:33 +00:00
Fergus Henderson
a0af8dbbb8 Update the expected output for these test cases to reflect what is
Estimated hours taken: 1

tests/invalid/Mmakefile:
tests/invalid/types.err_exp:
tests/invalid/qualified_cons_id2.err_exp:
	Update the expected output for these test cases to reflect what is
	actually output.  Enable these tests, and also prog_io_erroneous.m,
	since we now pass them.  For the tests which we still do not
	pass, document why we don't pass them.

tests/invalid/no_exports.m:
	Document what we ought to complain about for this test case.
1998-01-12 13:30:03 +00:00
Fergus Henderson
e3c532d3da Modify to reflect recently-changed error message:
Estimated hours taken: 0.25

tests/invalid/pragma_c_code_and_clauses1.err_exp:
	Modify to reflect recently-changed error message:
	s/... with clauses preceding/... with preceding clauses/
1998-01-10 07:51:45 +00:00
Peter Schachte
2f3ea6c2a6 Fix inappropriate warning message for purity markers.
Estimated hours taken:  3

Ripped out code to warn if impurity markers were put before non-atomic
goals.  Such errors are now handled in prog_io_goal.m, and a suitable
error message is printed by typecheck.m.  So the code in purity.m was
vestigial.  It was triggered by implied modes of semipure or impure
goals, because they are turned into conjunctions, which then appear to
have been marked {im,semi}pure.

compiler/purity.m:
	Ripped out no-longer-needed error checking code.
tests/hard_coded/purity.exp:
tests/hard_coded/purity.m:
	Add a regression test.
tests/invalid/purity_nonsense.err_exp:
tests/invalid/purity_nonsense.m:
	Add a `impure call(P)' test (should give a warning/error).
1998-01-06 06:31:42 +00:00
Fergus Henderson
a3883f9174 Delete the inferred modes from the expected output for this test.
Estimated hours taken: 0.25

tests/invalid/funcs_as_preds.err_exp:
	Delete the inferred modes from the expected output for this test.
	Modes for functions are now always assumed to be
	(in, in, ..., out) unless explicitly declared,
	rather than being inferred, so we don't print out any
	message about the inferred modes.
1998-01-06 02:41:02 +00:00
Fergus Henderson
239e96ec59 Clean up the handling of unbound type variables.
Estimated hours taken: 8

Clean up the handling of unbound type variables.
Fix a bug with unbound type variables in lambda expressions.
Run purity analysis, modechecking etc. even if there were type errors.

compiler/mercury_compile.m:
	Run purity analysis, modechecking etc. even if there were type
	errors.  This fixes a bug (inconsistency between the code and
	the comments) that seems to have been introduced in stayl's
	change to mercury_compile.m (revision 1.25) to add intermodule
	unused argument elimination: the comment said "continue,
	even if type checking found errors", but the code did not
	continue.

	This change was needed to ensure that we still report a warning
	message about unused type variables for tests/invalid/error2.m;
	without it, we stop after type checking and don't do purity
	analysis, and so don't report the warning.

compiler/typecheck.m:
compiler/purity.m:
	Move the code for checking for unbound type variables
	from typecheck.m to purity.m.  It needs to be done
	*after* type inference has been completed, so it
	can't be done in the ordinary type checking/inference
	passes.  Add code to purity.m to bind the
	unbound type variables to the builtin type `void'.

compiler/polymorphism.m:
	Comment out old code to bind unbound type variables
	to `void'; the old code was incomplete, and this
	is now done in purity.m.

compiler/notes/compiler_design.html:
	Document the above changes.

tests/valid/Mmakefile:
tests/valid/unbound_tvar_in_lambda.m:
	Regression test for the above-mentioned bug with unbound type
	variables in lambda expressions.

tests/warnings/singleton_test.exp:
tests/invalid/errors2.err_exp:
	Change the expected warning message for unbound type variables.
	The error context is not as precise as it used to be, I'm afraid:
	we only know which function/predicate the error occurred in,
	not which clause.  Also it now comes out in a different order
	relative to the other error messages.

tests/invalid/errors2.err_exp:
tests/invalid/funcs_as_preds.err_exp:
	Add some new error/warning messages that are output now that
	we run mode and determinism analysis even if there are type errors.
1998-01-02 00:11:41 +00:00
Andrew Bromage
7679b3a4f1 Re-undoing changes that I accidentally re-committed to the
tests/invalid/io_in_ite_cond.err_exp:
tests/invalid/mostly_uniq1.err_exp:
tests/invalid/mostly_uniq2.err_exp:
	Re-undoing changes that I accidentally re-committed to the
		wrong branch.
1997-12-29 05:07:56 +00:00
Andrew Bromage
8aa104f389 Updating tests/invalid on the alias branch. 1997-12-24 02:25:15 +00:00
Andrew Bromage
db2165d883 Undoing changes that I accidentally committed to the
tests/invalid/io_in_ite_cond.err_exp:
tests/invalid/mostly_uniq1.err_exp:
tests/invalid/mostly_uniq2.err_exp:
	Undoing changes that I accidentally committed to the
	wrong branch.
1997-12-24 01:08:02 +00:00
Andrew Bromage
dc97530dd5 Snapshot as of 22 Dec 1997. This snapshot both bootstraps and passes
all tests (except for a couple in tests/invalid which Fergus has since
fixed in the main branch).
1997-12-22 06:25:30 +00:00
Fergus Henderson
8ba58b05cf Fix a bug introduced during my recent change to unique mode analysis
(unique_modes.m) which made it do the same fixpoint analysis that
ordinary mode analysis (modes.m) does.

compiler/mercury_compile.m:
	Update to reflect recent change to unique_modes.m:
	unique mode checking now returns the error status in
	the module_info, rather than in the io__state exit status.

tests/invalid/mostly_uniq1.err_exp:
tests/invalid/mostly_uniq2.err_exp:
tests/invalid/io_in_ite_cond.err_exp:
	Undo recent work-around (which didn't work anyway),
	since the bug it works around is now fixed.
1997-12-10 02:35:27 +00:00
Peter Schachte
bf824facde Make Mercury cope with impure code
The purpose of this diff is to allow Mercury programs to contain
impure Mercury code without the compiler changing its behavior
inappropriately, while still allowing the compiler to aggressively
optimize pure code.  To do this, we require impure predicates to be so
declared, and calls to impure predicates to be flagged as such.  We
also allow predicates implemented in terms of impure predicates to be
promised to be pure; lacking such a promise, any predicate that calls
an impure predicate is assumed to be impure.

At the moment, we don't allow impure functions (only predicates),
though some of the work necessary to support them has been done.

Note that to make the operators work properly, the precedence of the
`pred' and `func' operators has been changed from 1199 to 800.

Estimated hours taken: 150

compiler/purity.m:
	New compiler pass for purity checking.
compiler/hlds_goal.m:
	Add `impure' and `semipure' to the goal_feature enum.
compiler/hlds_out.m:
compiler/typecheck.m:
compiler/special_pred.m:
	Fixed code that prints predicate name to write something more
	helpful for special (compiler-generated) predicates.  Added
	code to print new markers.  Added purity argument to
	mercury_output_pred_type.  New public predicate
	special_pred_description/2 provides an english description for
	each compiler-generated predicate.
compiler/hlds_pred.m:
	Add `impure' and `semipure' to marker enum.  Added new
	public predicates to get predicate purity and whether or not
	it's promised to be pure.
compiler/prog_data.m:
compiler/mercury_to_mercury.m:
compiler/prog_io.m:
compiler/prog_io_goal.m:
compiler/prog_io_pragma.m:
compiler/prog_io_dcg.m:
compiler/prog_util.m:
compiler/equiv_type.m:
compiler/intermod.m:
compiler/mercury_to_c.m:
compiler/module_qual.m:
	Add purity argument to pred and func items.  Add new `impure'
	and `semipure' operators.  Add promise_pure pragma.  Add
	purity/2 wrapper to goal_expr type.
compiler/make_hlds.m:
compiler/mercury_to_goedel.m:
	Added purity argument to module_add_{pred,func},
	clauses_info_add_pragma_c_code, and to pred and func items.
	Handle promise_pure pragma.  Handle purity/2 wrapper used to
	handle user-written impurity annotations on goals.
compiler/mercury_compile.m:
	Add purity checking pass between type and mode checking.
compiler/mode_errors.m:
	Distinguish mode errors caused by impure goals preventing
	goals being delayed.
compiler/modes.m:
	Don't delay impure goals, and ensure before scheduling an
	impure goal that no goals are delayed.  Actually, we go ahead
	and try to schedule goals even if impurity causes a problem,
	and then if it still doesn't mode check, then we report an
	ordinary mode error.  Only if the clause would be mode correct
	except for an impure goal do we report it as an impurity problem.
compiler/simplify.m:
	Don't optimize away non-pure duplicate calls.  We could do
	better and still optimize duplicate semipure goals without an
	intervening impure goal, but it's probably not worth the
	trouble.  Also don't eliminate impure goals on a failing branch.
compiler/notes/compiler_design.html:
	Documented purity checking pass.
doc/reference_manual.texi:
	Document purity system.
doc/transition_guide.texi:
library/nc_builtin.nl:
library/ops.m:
library/sp_builtin.nl:
	New operators and new precdence for `pred' and `func'
	operators.
tests/hard_coded/purity.m
tests/hard_coded/purity.exp
tests/hard_coded/Mmakefile:
tests/invalid/purity.m
tests/invalid/purity_nonsense.m
tests/invalid/purity.err_exp
tests/invalid/purity_nonsense.err_exp
tests/invalid/Mmakefile:
	Test cases for purity.
1997-12-09 04:02:47 +00:00
Fergus Henderson
e2ee1b8cab Update to reflect changes to the layout of certain error messages
Estimated hours taken: 0.25

tests/invalid/type_mismatch.err_exp:
	Update to reflect changes to the layout of certain error messages
	caused by a recent change to typecheck.m.
1997-12-07 08:56:01 +00:00
Fergus Henderson
6a1ebf2aea Delete a few occurrences of
Estimated hours taken: 0.25

tests/invalid/io_in_ite_cond.err_exp:
tests/invalid/mostly_uniq1.err_exp:
tests/invalid/mostly_uniq2.err_exp:
	Delete a few occurrences of
	"For more information, try recompiling with `-E'."
	from the expected error messages.
	This is actually due to a bug introduced in my
	recent changes to unique_modes.m -- it is not setting
	the exit status correctly.  Oh well, changing the test
	case will shut it up for a while...
1997-12-02 14:07:57 +00:00
Fergus Henderson
115b71f83b Report an error for duplicate mode declarations.
Estimated hours taken: 3

Report an error for duplicate mode declarations.

compiler/modes.m:
	Check for duplicate mode declarations.

compiler/modecheck_call.m:
	Add new predicate modes_are_indistinguishable, for use by modes.m.

compiler/mode_errors.m:
	Add predicate report_indistinguishable_mode_error to mode_errors.m,
	so that modes.m can use it to report duplicate mode declarations.

compiler/mode_errors.m:
compiler/mercury_to_mercury.m:
	Move some code in mode_errors.m into a new predicate
	mercury_output_mode_subdecls/8 in mercury_to_mercury.m.

compiler/make_hlds.m:
	Update a few comments.

tests/invalid/Mmakefile:
tests/invalid/duplicate_modes.m:
tests/invalid/duplicate_modes.err_exp:
	Test cases for the above change.
1997-11-23 05:18:41 +00:00
Simon Taylor
0c367104de Disallow pragma c_code without determinism declarations.
Estimated hours taken: 0.5

compiler/det_analysis.m
compiler/det_report.m
        Disallow pragma c_code without determinism declarations.


tests/invalid/pragma_c_code_no_det.m
tests/invalid/pragma_c_code_no_det.err_exp
        Test case.
1997-11-17 05:48:44 +00:00
Fergus Henderson
fa8a94feaf Improve the error messages for certain kinds of syntax errors,
Estimated hours taken: 1

Improve the error messages for certain kinds of syntax errors,
where variables occur in places that they shouldn't.

compiler/prog_io_goal.m:
	Change parse_qualified_term to take an extra argument,
	the "containing" term, in case the term being parsed
	is a term__variable, which will not have a term__context.
	Use the new argument to give better error messages.

compiler/make_hlds.m:
compiler/prog_io.m:
compiler/prog_io_dcg.m:
compiler/prog_io_pragma.m:
compiler/prog_io_util.m:
	Changed calls to parse_qualified_term to pass the new argument.

tests/invalid/Mmakefile:
tests/invalid/vars_in_wrong_places.m:
tests/invalid/vars_in_wrong_places.err_exp:
	Test cases for the above change.
1997-11-02 12:29:48 +00:00
Zoltan Somogyi
3e774cccd7 Emit better error messages when the type of a function symbol is known
Estimated hours taken: 4

compiler/typecheck.m:
	Emit better error messages when the type of a function symbol is known
	and some of the arguments have the wrong type.

tests/invalid/type_mismatch.{m,err_exp}:
	A new test case to exercise the new error messages.

tests/invalid/Mmakefile:
	Enable the new test case.
1997-10-14 06:38:37 +00:00
Fergus Henderson
6e06050558 Rename Mmake' as Mmakefile', since using the name `Mmake'
Estimated hours taken: 0.25

*/Mmake:
	Rename `Mmake' as `Mmakefile', since using the name `Mmake'
	causes problems on case-insensitive file systems.
1997-09-29 18:05:38 +00:00
Fergus Henderson
e6b019ee08 Fix a bug: the compiler was not checking for unbound inst variables
Estimated hours taken: 2

Fix a bug: the compiler was not checking for unbound inst variables
in mode declarations.

compiler/typecheck.m:
compiler/inst_match.m:
	Add code to check for unbound inst variables.

tests/invalid/Mmake:
tests/invalid/unbound_inst_var.m:
tests/invalid/unbound_inst_var.err_exp:
	Regression test.
1997-09-29 06:12:50 +00:00
Fergus Henderson
57af1d1b8d Fix a bug where the compiler reported an internal error `unify_inst failed'
Estimated hours taken: 6

Fix a bug where the compiler reported an internal error `unify_inst failed'
for certain ill-moded calls involving `any' insts.

compiler/inst_util.m:
	Add code in abstractly_unify_inst to handle some more cases
	of `any' that previously we didn't allow; specifically, the case
	of unifying a `bound' or `ground' inst with `any'.
	The new cases are allowed only in the `fake_unify' case, not in
	the `real_unify' case, because code generation doesn't yet
	support these cases.

	Also fix a couple of unrelated bugs in abstractly_unify_inst
	where the `live' case was passing `dead' rather than `live'
	to unify_uniq.

compiler/prog_data.m:
	Add a new compiler-generated inst name `any_inst', similar to
	`ground_inst', but for insts resulting from unification with
	`any' rather than unification with `ground'.

compiler/hlds_data.m:
	Any a new `any_inst' table, similar to the `ground_inst' table.

compiler/mercury_to_mercury.m:
compiler/mode_util.m:
	Minor changes to handle new `any_inst' insts.

compiler/inst_util.m:
	Fix a couple of bugs

tests/invalid/Mmake:
tests/invalid/any_mode.m:
tests/invalid/any_mode.err_exp:
	Regression test for the above change.
1997-09-14 09:12:40 +00:00
Fergus Henderson
e814d7669a Update the expected output for one of the error messages,
Estimated hours taken: 0.25

tests/invalid/multisoln_func.err_exp:
	Update the expected output for one of the error messages,
	since I reformatted the error messages slightly.
1997-08-22 13:58:46 +00:00
Fergus Henderson
74dfe1af37 New test case to check that we correctly report errors
Estimated hours taken: 0.25

tests/invalid/Mmake:
tests/invalid/func_errors.m:
tests/invalid/func_errors.err_exp:
	New test case to check that we correctly report errors
	for certain invalid function declarations.
	(Mercury 0.6 failed this test case.)
1997-08-15 15:46:33 +00:00
Fergus Henderson
3636a59890 Change the expected error message to match what is actually output.
Estimated hours taken: 0.25

tests/nullary_ho_func_error.err_exp:
	Change the expected error message to match what is actually output.
1997-07-25 02:03:43 +00:00
Fergus Henderson
be4b9f1d20 Allow zero-arity higher-order function terms.
compiler/typecheck.m:
compiler/modecheck_unify.m:
	Allow apply/1.

compiler/mercury_to_mercury.m:
	Fix the output of nullary higher-order function insts:
	previously it would output `(func() = Mode is Det)',
	but the correct output is `((func) = Mode is Det)'.

doc/reference_manual.texi:
	Document that zero-arity higher-order function
	types, insts, modes, lambda expressions, and applications
	are allowed.

tests/hard_coded/Mmake:
tests/hard_coded/nullary_ho_func.m:
tests/hard_coded/nullary_ho_func.exp:
tests/invalid/Mmake:
tests/invalid/nullary_ho_func_error.m:
tests/invalid/nullary_ho_func_error.err_exp:
	Test cases relating to the above change.
1997-07-23 15:37:01 +00:00
Fergus Henderson
eef924930d If the tests succeeded, remove the `.allres' file, rather than
Estimated hours taken: 0.25

test/*/runtests:
	If the tests succeeded, remove the `.allres' file, rather than
	leaving it lying around.
1997-07-14 03:18:46 +00:00
Fergus Henderson
a7146dde20 Very minor change to the expected output for this test
Estimated hours taken: 0.1

tests/invalid/multisoln_func.err_exp:
	Very minor change to the expected output for this test
	(capitalization & punctuation) to match what is actually output.
1997-07-07 08:34:26 +00:00
Fergus Henderson
469a26b218 Report an error if a "forward" mode of a function,
Estimated hours taken: 2

compiler/det_report.m:
	Report an error if a "forward" mode of a function,
	(a mode for which all the arguments are fully input)
	has determinism nondet, multi, cc_nondet or cc_multi.
	Such functions should be illegal because they break
	referential transparency.

doc/reference_manual.texi:
	Document the above change.

tests/invalid/Mmake:
tests/invalid/multisoln_func.m:
	Test cases for the above change.
1997-07-03 14:40:14 +00:00
Simon Taylor
9a23c8e1ac Test cases for `:- use_module'
Estimated hours taken: 0.1

tests/invalid/errors.m
tests/invalid/errors2.m
	Test cases for `:- use_module'
1997-06-29 23:24:38 +00:00
Tyson Dowd
ea6ba74472 Implement `:- pragma no_inline'. This pragma prevents the compiler from
Estimated hours taken: 3

Implement `:- pragma no_inline'. This pragma prevents the compiler from
inlining predicates.

compiler/higher_order.m:
compiler/unused_args.m:
	Create new preds using entire marker list, rather than just
	inlining.

compiler/hlds_out.m:
compiler/mercury_to_mercury.m:
compiler/module_qual.m:
compiler/prog_data.m:
compiler/prog_io_pragma.m:
	Add code to support no_inline marker and pragma.

compiler/hlds_pred.m:
	Add `no_inline' marker.
	Create new preds using entire marker list, rather than just
	inlining.
	Change `pred_info_is_inlined' to `pred_info_requested_inlining',
	as it was inappropriately named, and added
	`pred_info_requested_no_inlining'.

compiler/inlining.m:
	Don't inline predicates with pragma no_inlines

compiler/intermod.m:
	Use `pred_info_requested_inlining'.

compiler/make_hlds.m:
	Add code to check for conflicting markers, check for conflicts
	between `inline' and `no_inline' markers.
	Add `no_inline' markers.
	Rename pragma_set_markers as pragma_add_markers, as it was
	actually adding extra markers to what was already there.

doc/reference_manual.texi:
	Document no_inline.

tests/hard_coded/Mmake:
tests/invalid/Mmake:
tests/hard_coded/no_inline.exp:
tests/hard_coded/no_inline.m:
tests/invalid/inline_conflict.err_exp:
tests/invalid/inline_conflict.m:
	Add test cases for no_inline and conflicts between inline and
	no_inline.
1997-06-27 04:05:22 +00:00
Fergus Henderson
a05ff8c5b6 Fix a bug: for higher-order types, avoid calling
Estimated hours taken: 1

compiler/mode_util.m:
	Fix a bug: for higher-order types, avoid calling
	propagate_types_into_mode_list if the length of the
	argument types doesn't match the length of the argument modes,
	because that would cause a call to error/1.

tests/invalid/Mmake:
tests/invalid/ho_type_mode_bug.m:
tests/invalid/ho_type_mode_bug.exp:
	Regression test for the above-mentioned bug.

tests/invalid/Mmake:
	Use `$(MC) $(MCFLAGS)' rather than hard-coding `mc'.
1997-06-16 08:58:01 +00:00