Files
mercury/tests/invalid/instance_var_bug.m
Julien Fischer dc1e59e48b Fix a bug (#27) reported by Ralph. The compiler was aborting on
Estimated hours taken: 1
Branches: main

Fix a bug (#27) reported by Ralph.  The compiler was aborting on
instances that contained type variables that were not wrapped in functors.
The problem is that the name mangling scheme used to mangle the names of
method wrapper predicates cannot handle instances that contain unwrapped
type variables.  The compiler already has code to check for this, but that
check was not being performed until *after* it had attempted to introduce
the method wrapper predicates.

The fix is to reorder the phases of check_typeclass.m so that we perform
the check on the types in an instance first and only run the remaining
phases if the first one succeeds.

compiler/check_typeclass.m:
	Reorder the phases within this module so that we don't attempt
	to introduce method wrapper predicates for invalid instances.

	Update the documentation in this module to conform to the above
	change.

	Remove some unnecessary module qualification.

tests/invalid/Mercury.options:
tests/invalid/Mmakefile:
tests/invalid/instance_var_bug.{m,err_exp}:
	Test for the above bug.

tests/invalid/bad_instance.err_exp:
	Update this.  The error message for the missing concrete instance
	won't be emitted with the above change.  Note, we have a separate
	test case, tests/invalid/missing_concrete_instance, that exercises
	that error message.
2007-11-14 04:00:06 +00:00

15 lines
624 B
Mathematica

% This program cause the following assertion failure in rotd-2007-11-11:
%
% Software Error: hlds_code_util.m: Unexpected: type_to_string: invalid type
%
% The problem was that the name mangling scheme used for the names of method
% wrapper predicates cannot handle type variables. The compiler should
% have been reporting the instance tc(V) as an error anyway, but it wasn't
% doing that check until *after* it had attempted to add the method wrapper.
%
:- module instance_var_bug.
:- interface.
:- typeclass tc(T) where [ pred p(T::in) is semidet ].
:- implementation.
:- instance tc(V) where [ p(_) :- semidet_true ].