Commit Graph

8 Commits

Author SHA1 Message Date
Zoltan Somogyi
4865f11503 Update programming style. 2020-10-04 13:20:42 +11:00
Zoltan Somogyi
33eb3028f5 Clean up the tests in half the test directories.
tests/accumulator/*.m:
tests/analysis_*/*.m:
tests/benchmarks*/*.m:
tests/debugger*/*.{m,exp,inp}:
tests/declarative_debugger*/*.{m,exp,inp}:
tests/dppd*/*.m:
tests/exceptions*/*.m:
tests/general*/*.m:
tests/grade_subdirs*/*.m:
tests/hard_coded*/*.m:
    Make these tests use four-space indentation, and ensure that
    each module is imported on its own line. (I intend to use the latter
    to figure out which subdirectories' tests can be executed in parallel.)

    These changes usually move code to different lines. For the debugger tests,
    specify the new line numbers in .inp files and expect them in .exp files.
2015-02-14 20:14:03 +11:00
Julien Fischer
bcec8a99e7 Remove support for the `initialisation is ...' attribute from solver types.
Estimated hours taken: 2
Branches: main

Remove support for the `initialisation is ...' attribute from solver types.
This attribute is now a syntax error, unless the developer-only option
`--solver-type-auto-init' is enabled -- in which case things will work
as before.

Update the test suite to conform to the above change.

compiler/globals.m:
	Add a mutable that stores whether or not we support automatic
	solver type initialisation.  The value of this mutable is used in
	the parser to decide if `initialisation is ...' attributes in solver
	type definitions are legal syntax or not.

compiler/prog_io.m:
	Only accept `initialisation is ...' attributes in solver type
	definitions as legal syntax if the value of the above mutable indicates
	that `--solver-type-auto-init' is enabled.

NEWS:
	Announce the removal of support for automatic initialisation.

tests/debugger/Mercury.options:
	Run the solver_test test with `--solver-type-auto-init' enabled.

tests/hard_coded/Mercury.options:
	Run tests that check if automatic initialisation is working
	with `--solver-type-auto-init' enabled.

	Delete a reference to a test case was deleted some time ago.


tests/warnings/Mercury.options:
tests/invalid/Mercury.options:
	Enable `--solver-type-auto-init' for some tests.

tests/invalid/any_mode.m:
tests/invalid/any_passed_as_ground.m:
tests/invalid/any_should_not_match_bound.m:
tests/invalid/any_ground_in_ite_cond.m:
tests/valid/solv.m:
tests/hard_coded/any_call_hoist_bug.m:
tests/hard_coded/any_free_unify.m:
tests/hard_coded/sub-modules/ts.m:
	Remove `initialisation is ...' attributes from the solver type
	definitions in these tests.
2007-11-14 03:45:14 +00:00
Ralph Becket
684ecfbd55 Undo my recent changes to purity error checking in the context of inst any
Estimated hours taken: 16
Branches: main

Undo my recent changes to purity error checking in the context of inst any
non-locals in negated contexts.

Implement a better way of handling the problem, as discussed on the mailing
list.  The new solution is to require that any goals featuring inst any
non-locals in a negated context must appear in a
promise_{pure,semipure,impure} context.  This is something of a compromise:
on the one hand it does require that the condition be explicitly recognised
by the programmer; on the other, it does not require that the "offending" goals
be individually identified (this is partly for pragmatic reasons: the earlier
approach required a plethora of awkward impurity declarations on goals that
would otherwise be considered completely pure).

compiler/mode_errors.m:
	Remove purity_error_should_be_impure and purity_error_wrongly_impure
	data constructors; add purity_error_should_be_in_promise_purity_scope.

compiler/mode_info.m:
	Replace the in_negated_context field with the in_promise_purity_scope
	field.

compiler/modecheck_call.m:
compiler/modecheck_unify.m:
	Back out my previous change.

compiler/modes.m:
	Record a purity error if a non-local inst any variable appears
	in a negation or the condition of an if-then-else goal.

compiler/purity.m:
compiler/unique_modes.m:
	Back out my previous change.

doc/reference_manual.texi:
	Document the new purity rules for inst any non-locals in negated
	contexts.

tests/debugger/solver_test.m:
tests/hard_coded/any_free_unify.m:
tests/invalid/any_passed_as_ground.m:
tests/invalid/any_to_ground_in_ite_cond.m:
tests/invalid/anys_in_negated_contexts.err_exp:
tests/invalid/anys_in_negated_contexts.m:
tests/invalid/purity/impure_func_t7.err_exp:
tests/invalid/purity/impure_func_t7.m:
	Fix up error cases to use the new syntax.
2005-12-14 05:14:17 +00:00
Ralph Becket
f594153eb0 Bugfix: solver type foo lacked a definition.
Estimated hours taken: 0.1
Branches: main

tests/hard_coded/any_free_unify.m:
	Bugfix: solver type foo lacked a definition.
2004-09-21 07:40:22 +00:00
Ralph Becket
f8312974e4 Bugfixes (mostly) related to the recent solver types changes.
Estimated hours taken: 3
Branches: main

Bugfixes (mostly) related to the recent solver types changes.

compiler/type_util.m:
	Having the compiler assume that type variables denote solver types
	causes the compiler to throw an exception when it tries to compile the
	initialisation forwarding predicate for exported abstract type foo(T)
	defined as foo(T) == T.

	The right solution at some point is to introduce a solver type class.

	type_util__is_solver_type no longer assumes that type variables
	denote solver types.

compiler/prog_io.m:
	Fixed a bug in make_maybe_where_details where a solver type without
	user defined equality or comparison would get a
	`yes(unify_compare(no, no))' result rather than just `no'.

tests/invalid/partial_implied_mode.err_exp2:
	Copy of partial_implied_mode.err_exp, but with different temporary
	variable names in the expected compiler errors.

tests/invalid/any_mode.m:
tests/invalid/any_mode.err_exp:
tests/invalid/any_should_not_match_bound.m:
tests/invalid/any_should_not_match_bound.err_exp:
	Updated code and expected error.

tests/misc_tests/pretty_print_test.exp:
	Corrected expected error.
2004-09-10 03:50:30 +00:00
David Overton
2ad2f0a28e Allow types to be declared as "solver" types using the syntax
Estimated hours taken: 120
Branches: main

Allow types to be declared as "solver" types using the syntax
`:- solver type ...'.

For a non-solver type t (i.e. any type declared without using the
`solver' keyword), the inst `any' should be considered to be equivalent
to a bound inst i where i contains all the functors of the type t and
each argument has inst `any'.  For solver types, `any' retains its
previous meaning.

This is required to allow us to represent HAL's `old' inst using `any'.
In HAL, `old' is like `any' if the type is an instance of a particular
type class (`solver/1').  However, for types that are not instances of
`solver/1', `old' needs to be treated as though it is `bound'.

library/ops.m:
	Add `solver' as a unary prefix operator.

compiler/prog_data.m:
	Add a field to the type `type_defn' to record whether or not the
	type is a solver type.

compiler/hlds_data.m:
	Add an equivalent field to the type `hlds_type_body'.

compiler/prog_io.m:
compiler/make_hlds.m:
compiler/modules.m:
compiler/mercury_to_mercury.m:
compiler/hlds_out.m:
	Handle the new ":- solver type ..." syntax.

compiler/det_report.m:
compiler/equiv_type.m:
compiler/foreign.m:
compiler/hlds_code_util.m:
compiler/hlds_out.m:
compiler/intermod.m:
compiler/magic_util.m:
compiler/ml_code_gen.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds.m:
compiler/module_qual.m:
compiler/post_typecheck.m:
compiler/pragma_c_gen.m:
compiler/recompilation.check.m:
compiler/recompilation.usage.m:
compiler/recompilation.version.m:
compiler/special_pred.m:
compiler/stack_opt.m:
compiler/switch_util.m:
compiler/table_gen.m:
compiler/term_util.m:
compiler/type_ctor_info.m:
compiler/unify_gen.m:
compiler/unify_proc.m:
	Handle the changes to `type_defn' and `hlds_type_body'.

compiler/type_util.m:
	Add predicates `type_util__is_solver_type' and
	`type_body_is_solver_type'.

compiler/inst_match.m:
compiler/inst_util.m:
	In inst_matches_{initial,final,binding} and
	abstractly_unify_inst_functor, when we are comparing `any' insts, check
	whether or not the type is a solver type and treat it appropriately.

compiler/instmap.m:
compiler/modecheck_unify.m:
	Pass type information to abstractly_unify_inst_functor.

compiler/mode_util.m:
	Add a predicate `constructors_to_bound_any_insts' which is the same as
	`constructors_to_bound_insts' except that it makes the arguments of the
	bound inst `any' instead of `ground'.

tests/invalid/any_mode.m:
tests/invalid/any_mode.err_exp:
tests/hard_coded/any_free_unify.m:
	Modify these test cases to use a "solver" type instead of `int'.

tests/valid/any_matches_bound.m:
tests/valid/Mmakefile:
tests/invalid/Mmakefile:
tests/invalid/any_should_not_match_bound.m:
tests/invalid/any_should_not_match_bound.err_exp:
	Add new test cases.

extras/trailed_update/var.m:
clpr/cfloat.m:
	Modify to use the new `:- solver type' syntax.
2003-07-25 02:27:37 +00:00
David Overton
421a4e6558 Allow more precise (i.e. less conservative) mode checking in the case that an
Estimated hours taken: 7
Branches: main

Allow more precise (i.e. less conservative) mode checking in the case that an
`any' inst occurs in a negated context.  Normally we must disallow this
because we do not know whether the inst has become more instantiated over the
negated goal.  However, if the inst has simply been unified with `free' then
we know that it cannot have become more instantiated.  This change checks
for, and allows, that case.

This situation occurs quite frequently in code generated by the HAL compiler.

compiler/inst_match.m:
	Add a new inst comparison predicate
	`inst_is_at_least_as_instantiated' which is the same as
	`inst_matches_initial' except that it reverses the uniqueness
	comparison.
	Add a new variant of `inst_matches_binding' which allows `any' to match
	`any'.

compiler/modecheck_unify.m:
	When mode checking a unification, in the call to
	`modecheck_set_var_inst' pass the initial inst of the other side of
	the unification.

compiler/modes.m:
	Modify `modecheck_set_var_inst' so that in the case that the inst to
	be set is the final inst in a unification goal and the initial inst
	of the other side of the unification is available then it can make
	use of that information to improve the precision of the analysis.

tests/hard_coded/Mmakefile:
tests/hard_coded/any_free_unify.exp:
tests/hard_coded/any_free_unify.m:
tests/invalid/Mmakefile:
tests/invalid/bind_in_negated.m:
tests/invalid/bind_in_negated.err_exp:
	Add some test cases.
2003-06-02 04:56:31 +00:00