]> code.delx.au - gnu-emacs/blobdiff - test/indent/prolog.prolog
Uncomment the next-error-function integration in xref
[gnu-emacs] / test / indent / prolog.prolog
index 6cb5535fe8df0442dc2f905b83589f1f697a6688..9ac6df1b6c754428099fdbcdd0f57c66149c5b00 100644 (file)
@@ -1,5 +1,52 @@
 %% -*- mode: prolog; coding: utf-8; fill-column: 78 -*-
 
+%% bug#21526
+test21526_1 :-
+    (   a ->
+        (   a ->
+            b
+        ;   c
+        )
+    ;   % Toto
+        c ->
+        d
+    ).
+
+test21526_2 :-
+    (    a
+    ->   (   a,
+             b
+         ;   c
+         ),
+         b2
+    ;    c1,
+         c2
+    ).
+
+test21526_3 :-
+    X \= Y,
+    \+ a,
+    b,
+    \+ \+ c,
+    d.
+
+test21526_4 :-
+    (   \+ a ->
+        b
+    ;   \+ c,
+        \+ d
+    ).
+
+
+test21526_5 :-
+    (a;
+     b ->
+         c).
+
+test21526_predicate(c) :- !,
+    test_goal1,
+    test_goal2.
+
 %% Testing correct tokenizing.
 foo(X) :- 0'= = X.
 foo(X) :- 8'234 = X.
@@ -48,7 +95,19 @@ subst(X, V, FV, lambda(Y, Ti, Bi), lambda(Y1, To, Bo)) :-
           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)) :-
@@ -200,7 +259,7 @@ elaborate(fix(F,T,B,E), Env, Ee) :-
     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),