]> Repositorios git - scryer-prolog.git/commitdiff
fix overeager detection of (->)/2 in if position of (;)/2 (#2183)
authorMark <[email protected]>
Wed, 29 Nov 2023 17:51:55 +0000 (10:51 -0700)
committerMark <[email protected]>
Wed, 29 Nov 2023 18:05:04 +0000 (11:05 -0700)
src/machine/disjuncts.rs

index e07122655b017cf22fb27f76d1beeb754705aae5..d3fc6a885372b684f77098a5cdc5d19434a49a91 100644 (file)
@@ -663,12 +663,16 @@ impl VariableClassifier {
                                 state_stack.last(),
                                 Some(TraversalState::RemoveBranchNum)
                             ) {
-                                // check if the second-to-last element is a regular BuildDisjunct, as we don't
-                                // want to add GetPrevLevel in case of a TrustMe.
-                                matches!(
-                                    state_stack.iter().rev().nth(1),
-                                    Some(TraversalState::BuildDisjunct(..))
-                                )
+                                // check if the second-to-last element
+                                // is a regular BuildDisjunct, as we
+                                // don't want to add GetPrevLevel in
+                                // case of a TrustMe.
+                                match state_stack.iter().rev().nth(1) {
+                                    Some(&TraversalState::BuildDisjunct(preceding_len)) => {
+                                        preceding_len + 1 == build_stack.len()
+                                    }
+                                    _ => false,
+                                }
                             } else {
                                 false
                             };