Files
mercury/tests/invalid/errors2.err_exp
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

70 lines
4.0 KiB
Plaintext

errors2.m:009: Error: clause for predicate `errors2:bind_type_param/1'
errors2.m:009: without preceding `pred' declaration.
errors2.m:052: In clause for predicate `errors2:type_error_4/0':
errors2.m:052: warning: variable `X' occurs only once in this scope.
errors2.m:059: In clause for predicate `errors2:type_error_5/0':
errors2.m:059: warning: variable `X' occurs only once in this scope.
errors2.m:065: In clause for predicate `errors2:type_error_6/0':
errors2.m:065: warning: variable `X' occurs only once in this scope.
errors2.m:070: In clause for predicate `errors2:type_error_7/0':
errors2.m:070: warning: variable `Y' occurs only once in this scope.
errors2.m:071: In clause for predicate `errors2:type_error_7/0':
errors2.m:071: warning: variables `Z, A, B' occur only once in this scope.
errors2.m:007: Error: no clauses for predicate `errors2:bind_type_param/2'
errors2.m:023: Error: no clauses for predicate `errors2:produce_string/1'
errors2.m:025: Error: no clauses for predicate `errors2:expect_int/1'
errors2.m:031: In clause for predicate `errors2:type_error/0':
errors2.m:031: in argument 1 of call to pred `expect_int/1':
errors2.m:031: type error: variable `X' has type `string',
errors2.m:031: expected type was `int'.
errors2.m:037: In clause for predicate `errors2:type_error_2/0':
errors2.m:037: type error in unification of variable `X'
errors2.m:037: and variable `Y'.
errors2.m:037: `X' has type `string',
errors2.m:037: `Y' has type `int'.
errors2.m:043: In clause for predicate `errors2:type_error_3/0':
errors2.m:043: in argument 1 of call to pred `expect_int/1':
errors2.m:043: type error: variable `Y' has type `string',
errors2.m:043: expected type was `int'.
errors2.m:052: In clause for predicate `errors2:type_error_4/0':
errors2.m:052: in argument 3 of functor `foo_functor/3':
errors2.m:052: type error in unification of argument
errors2.m:052: and constant `1.00000000000000'.
errors2.m:052: argument has type `string',
errors2.m:052: constant `1.00000000000000' has type `float'.
errors2.m:059: In clause for predicate `errors2:type_error_5/0':
errors2.m:059: in argument 3 of functor `foo_functor/3':
errors2.m:059: type error in unification of argument
errors2.m:059: and constant `1.00000000000000'.
errors2.m:059: argument has type `string',
errors2.m:059: constant `1.00000000000000' has type `float'.
errors2.m:065: In clause for predicate `errors2:type_error_6/0':
errors2.m:065: in argument 3 of functor `bar_functor/3':
errors2.m:065: type error in unification of argument
errors2.m:065: and constant `1.00000000000000'.
errors2.m:065: argument has type `string',
errors2.m:065: constant `1.00000000000000' has type `float'.
errors2.m:072: In clause for predicate `errors2:type_error_7/0':
errors2.m:072: in argument 1 of call to pred `expect_int/1':
errors2.m:072: type error: variable `C' has type `string',
errors2.m:072: expected type was `int'.
errors2.m:078: In clause for predicate `errors2:type_error_8/0':
errors2.m:078: in argument 1 of call to predicate `from_char_list/2':
errors2.m:078: error: undefined symbol `[]/0'.
errors2.m:078: In clause for predicate `errors2:type_error_8/0':
errors2.m:078: error: undefined predicate `from_char_list/2'.
errors2.m:009: Inferred :- pred bind_type_param(int).
errors2.m:016: In predicate `errors2:unresolved_polymorphism/0':
errors2.m:016: warning: unresolved polymorphism.
errors2.m:016: The variables with unbound types were:
errors2.m:016: V_2 :: TypeParam
errors2.m:016: Arg :: TypeParam
errors2.m:016: The unbound type variable(s) will be implicitly
errors2.m:016: bound to the builtin type `void'.
errors2.m:019: In clause for `unresolved_polymorphism':
errors2.m:019: in argument 1 of call to predicate `errors2:bind_type_param/2':
errors2.m:019: mode error: variable `Arg' has instantiatedness `free',
errors2.m:019: expected instantiatedness was `ground'.
errors2.m:009: Error: no mode declaration for predicate `errors2:bind_type_param/1'.
For more information, try recompiling with `-E'.