]> Repositorios git - scryer-prolog.git/commitdiff
resolve panic caused by lingering attribute goals (#253)
authorMark Thom <[email protected]>
Fri, 6 Dec 2019 19:22:28 +0000 (15:22 -0400)
committerMark Thom <[email protected]>
Fri, 6 Dec 2019 19:22:28 +0000 (15:22 -0400)
src/prolog/clause_types.rs
src/prolog/machine/system_calls.rs
src/prolog/toplevel.pl

index 37f9ada9915a6a43efe30a753874928402b2303e..006ea3d48bf148431766fda48babe9e73b3cc0ba 100644 (file)
@@ -166,6 +166,7 @@ pub enum SystemClauseType {
     CharCode,
     CharsToNumber,
     ClearAttrVarBindings,
+    ClearAttributeGoals,
     CloneAttributeGoals,
     CodesToNumber,
     CopyTermWithoutAttrVars,
@@ -266,6 +267,7 @@ impl SystemClauseType {
             &SystemClauseType::CallAttributeGoals => clause_name!("$call_attribute_goals"),
             &SystemClauseType::CharCode => clause_name!("$char_code"),
             &SystemClauseType::CharsToNumber => clause_name!("$chars_to_number"),
+            &SystemClauseType::ClearAttributeGoals => clause_name!("$clear_attribute_goals"),
             &SystemClauseType::CloneAttributeGoals => clause_name!("$clone_attribute_goals"),
             &SystemClauseType::CodesToNumber => clause_name!("$codes_to_number"),
             &SystemClauseType::CopyTermWithoutAttrVars => clause_name!("$copy_term_without_attr_vars"),
@@ -398,6 +400,7 @@ impl SystemClauseType {
             ("$char_code", 2) => Some(SystemClauseType::CharCode),
             ("$chars_to_number", 2) => Some(SystemClauseType::CharsToNumber),
             ("$clear_attr_var_bindings", 0) => Some(SystemClauseType::ClearAttrVarBindings),
+            ("$clear_attribute_goals", 0) => Some(SystemClauseType::ClearAttributeGoals),
             ("$clone_attribute_goals", 1) => Some(SystemClauseType::CloneAttributeGoals),
             ("$codes_to_number", 2) => Some(SystemClauseType::CodesToNumber),
             ("$copy_term_without_attr_vars", 2) => Some(SystemClauseType::CopyTermWithoutAttrVars),
index 11eb193e852f1df0d03b0acd8979dfc765ae9c08..2fb652d40ce3d9b883c5d364472e1f9b8deba171 100644 (file)
@@ -1376,6 +1376,9 @@ impl MachineState {
             &SystemClauseType::TruncateIfNoLiftedHeapGrowth => {
                 self.truncate_if_no_lifted_heap_diff(|_| Addr::Con(Constant::EmptyList))
             }
+            &SystemClauseType::ClearAttributeGoals => {
+                self.attr_var_init.attribute_goals.clear();
+            }
             &SystemClauseType::CloneAttributeGoals => {
                 let attr_goals = self.attr_var_init.attribute_goals.clone();
                 self.fetch_attribute_goals(attr_goals);
index 74df6a6f384193732f04ebbed31faa0721c4d19d..cf5616455a046c37b64fc31147e5b1dfaf0023bd 100644 (file)
@@ -44,7 +44,9 @@
     ),
     (  '$get_b_value'(B), call(Term), '$write_eqs_and_read_input'(B, VarList),
        !
-    ;  write('false.'), nl
+    %  clear attribute goal lists, which may be populated by
+    %  copy_term/3 prior to failure.
+    ;  '$clear_attribute_goals', write('false.'), nl 
     ).
 
 '$needs_bracketing'(Value, Op) :-
     ).
 '$gather_query_vars'([], []).
 
-'$is_a_different_variable'([Var = Binding | Pairs], Value) :-
+'$is_a_different_variable'([_ = Binding | Pairs], Value) :-
     (  Value == Binding, !
     ;  '$is_a_different_variable'(Pairs, Value)
     ).