Files
mercury/tests/invalid/coerce_instvar.m
Zoltan Somogyi 3dc4babb24 Update the style of more test cases.
And update expected output files for changes in line numbers.
2021-07-27 13:29:46 +10:00

42 lines
794 B
Mathematica

%---------------------------------------------------------------------------%
% vim: ts=4 sw=4 et ft=mercury
%---------------------------------------------------------------------------%
:- module coerce_instvar.
:- interface.
:- type foobar
---> foo
; bar.
:- type foo =< foobar
---> foo.
:- type fruit
---> apple
; orange
; lemon(foobar).
:- type citrus =< fruit
---> orange
; lemon(foo).
%---------------------------------------------------------------------------%
:- implementation.
:- pred good(citrus::in(I), fruit::out(I)) is det.
good(X, Y) :-
Y = coerce(X),
(
Y = orange
;
Y = lemon(foo)
).
:- pred bad(fruit::in(I), citrus::out(I)) is det.
bad(X, Y) :-
Y = coerce(X).