mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-20 03:43:51 +00:00
Estimated hours taken: 1/4 Fix test case... the compiler was getting tripped up by a different bug than the one this was meant to be testing. ts/valid/instance_superclass.m: Fixed so it doesn't have an unbound type variable. (Actually, I don't really see why the compiler thinks it is unbound).
31 lines
728 B
Mathematica
31 lines
728 B
Mathematica
:- module instance_superclass.
|
|
|
|
% This is a regression test for the case where there is a superclass
|
|
% relationship, and the instance declaration has a type variable in the
|
|
% instance type.
|
|
|
|
:- interface.
|
|
|
|
:- import_module list.
|
|
|
|
:- typeclass c1(T) where [ ].
|
|
:- typeclass c2(T) <= c1(T) where [ ].
|
|
|
|
:- instance c1(list(T)) where [ ].
|
|
:- instance c2(list(T)) where [ ].
|
|
|
|
:- pred p(T::in) is det.
|
|
|
|
:- implementation.
|
|
|
|
% The bug that this test case is checking for is at the creation of
|
|
% the typeclass info for this call: if the substitution from "T" in
|
|
% the typeclass decl to "list(T)" in the instance is applied
|
|
% recursively, an infinite loop results.
|
|
p(X) :- q([X]).
|
|
|
|
:- pred q(T) <= c2(T).
|
|
:- mode q(in) is det.
|
|
|
|
q(_).
|