Files
mercury/vim/syntax
Julien Fischer a25ba19ea0 Improve the error checking for mutable declarations.
Estimated hours taken: 12
Branches: main

Improve the error checking for mutable declarations.

Fix a bug with solver types and sub-modules reported by Peter Hawkins.

Workaround a bug with mutable declarations and sub-modules.  Currently,
the compiler aborts if there is a mutable declaration in the parent module.
With this change mutable declarations will not be visible in child modules.

XXX This is not correct since they should be visible, but this can be fixed
as a separate change.

compiler/prog_data.m:
	Extend the item_origin type with information about what
	source-to-source transformations are responsible for compiler
	introduced items.  We need this information for error checking mutable
	declarations.  It also provides an additional layer of sanity checking
	in the parse tree.

	Add origin fields to the clause and initialise items, since they can
	both now be introduced by source-to-source transformations.

compiler/prog_io.m:
compiler/prog_io_dcg.m:
compiler/prog_io_typeclass.m:
	Conform to the above change.

compiler/make_hlds_passes.m:
	Don't issue spurious errors about initialise declarations that were
	introduced by the transformation for mutable declarations.  Abort if
	invalid initialise declarations were introduced by other compiler
	passes since this indicates a bug in the compiler.

	Check if mutable declarations occur in the interface of a module and
	emit an error if they do.

	Don't generate initialise items and foreign code from a mutable
	declaration unless we are in the defining module for the mutable
	declaration.

	Don't generate foreign_procs for solver types *unless* we are in the
	defining module.  Doing otherwise breaks the compiler when using
	solver types and sub-modules.

	Fix the formatting of an error message concerning initialise decls.
	s/foreign_code/foreign_proc/ in a spot.

compiler/add_solver.m:
compiler/mercury_to_mercury.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
compiler/add_class.m:
compiler/add_pragma.m:
compiler/state_var.m:
	Conform to the above changes.

compiler/modules.m:
	Handle mutable declarations in private interfaces.

	Clean up some code related to foreign_import_module decls.

	Conform to the changes in prog_data.m.

compiler/prog_util.m:
	Shift the functions for mutable access predicates and variables to
	this module.  The code that generates interface files also needs to be
	able to access them.

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

	Fix a bug where the context in the mq_info structure was not being
	updated.  This caused error messages for mutable declarations that
	contain undefined types or insts to have the wrong context.

compiler/hlds_data.m:
	Fix a typo.

vim/syntax/mercury.vim:
	Highlight `mutable' and `untrailed' appropriately.

tests/hard_coded/sub-modules/Mmakefile:
tests/hard_coded/sub-modules/ts.m:
tests/hard_coded/sub-modules/ts.tsub.m:
tests/hard_coded/sub-modules/ts.exp:
	Add Peter Hawkin's test case for the bug with solver
	types and sub-modules.

tests/invalid/Mmakefile:
tests/invalid/bad_mutable.m:
tests/invalid/bad_mutable.err_exp:
	Add a test for the various sorts of errors that can occur with mutable
	declarations.
2005-09-12 03:05:51 +00:00
..