%% -*- mode: prolog; coding: utf-8; fill-column: 78 -*-
+%% bug#21526
+test1 :-
+ ( a ->
+ ( a ->
+ b
+ ; c
+ )
+ ; c
+ ).
+
+test2 :-
+ ( a
+ -> ( a,
+ b
+ ; c
+ ),
+ b2
+ ; c1,
+ c2
+ )
+
%% Testing correct tokenizing.
foo(X) :- 0'= = X.
foo(X) :- 8'234 = X.
subst(Y, Y1, [], Bi, Bi1);
Y1 = Y, Bi1 = Bi),
%% Perform substitution on the body.
- subst(X, V, FV, Bi1, Bo)).
+ subst(X, V, FV, Bi1, Bo)),
+ ( X = Y
+ %% If X is equal to Y, X is shadowed, so no subst can take place.
+ -> Y1 = Y, Bo = Bi
+ ; (member((Y, _), FV)
+ %% If Y appears in FV, it can appear in V, so we need to
+ %% rename it to avoid name capture.
+ -> new_atom(Y, Y1),
+ subst(Y, Y1, [], Bi, Bi1)
+ ; Y1 = Y, Bi1 = Bi),
+ %% Perform substitution on the body.
+ subst(X, V, FV, Bi1, Bo)
+ ).
subst(X, V, FV, pi(Y, Ti, Bi), pi(Y1, To, Bo)) :-
subst(X, V, FV, lambda(Y, Ti, Bi), lambda(Y1, To, Bo)).
subst(X, V, FV, forall(Y, Ti, Bi), forall(Y1, To, Bo)) :-
elaborate(let(F,T,app(fix,lambda(F,T,B)),E), Env, Ee).
%% elab_bindings(+TS, +Env, -TS).
-%% Applique `elaborate' sur l'environnment de type TS.
+%% Applique `elaborate' sur l'environnement de type TS.
elab_tenv([], _, []).
elab_tenv([(X,T)|TS], Env, [(X, Tg)|TSe]) :-
elaborate(T, Env, Te),