resolve panic caused by lingering attribute goals (#253)

This commit is contained in:
Mark Thom
2019-12-06 15:22:28 -04:00
parent 90e1c990e5
commit 5ccd334555
3 changed files with 10 additions and 2 deletions

View File

@@ -166,6 +166,7 @@ pub enum SystemClauseType {
CharCode, CharCode,
CharsToNumber, CharsToNumber,
ClearAttrVarBindings, ClearAttrVarBindings,
ClearAttributeGoals,
CloneAttributeGoals, CloneAttributeGoals,
CodesToNumber, CodesToNumber,
CopyTermWithoutAttrVars, CopyTermWithoutAttrVars,
@@ -266,6 +267,7 @@ impl SystemClauseType {
&SystemClauseType::CallAttributeGoals => clause_name!("$call_attribute_goals"), &SystemClauseType::CallAttributeGoals => clause_name!("$call_attribute_goals"),
&SystemClauseType::CharCode => clause_name!("$char_code"), &SystemClauseType::CharCode => clause_name!("$char_code"),
&SystemClauseType::CharsToNumber => clause_name!("$chars_to_number"), &SystemClauseType::CharsToNumber => clause_name!("$chars_to_number"),
&SystemClauseType::ClearAttributeGoals => clause_name!("$clear_attribute_goals"),
&SystemClauseType::CloneAttributeGoals => clause_name!("$clone_attribute_goals"), &SystemClauseType::CloneAttributeGoals => clause_name!("$clone_attribute_goals"),
&SystemClauseType::CodesToNumber => clause_name!("$codes_to_number"), &SystemClauseType::CodesToNumber => clause_name!("$codes_to_number"),
&SystemClauseType::CopyTermWithoutAttrVars => clause_name!("$copy_term_without_attr_vars"), &SystemClauseType::CopyTermWithoutAttrVars => clause_name!("$copy_term_without_attr_vars"),
@@ -398,6 +400,7 @@ impl SystemClauseType {
("$char_code", 2) => Some(SystemClauseType::CharCode), ("$char_code", 2) => Some(SystemClauseType::CharCode),
("$chars_to_number", 2) => Some(SystemClauseType::CharsToNumber), ("$chars_to_number", 2) => Some(SystemClauseType::CharsToNumber),
("$clear_attr_var_bindings", 0) => Some(SystemClauseType::ClearAttrVarBindings), ("$clear_attr_var_bindings", 0) => Some(SystemClauseType::ClearAttrVarBindings),
("$clear_attribute_goals", 0) => Some(SystemClauseType::ClearAttributeGoals),
("$clone_attribute_goals", 1) => Some(SystemClauseType::CloneAttributeGoals), ("$clone_attribute_goals", 1) => Some(SystemClauseType::CloneAttributeGoals),
("$codes_to_number", 2) => Some(SystemClauseType::CodesToNumber), ("$codes_to_number", 2) => Some(SystemClauseType::CodesToNumber),
("$copy_term_without_attr_vars", 2) => Some(SystemClauseType::CopyTermWithoutAttrVars), ("$copy_term_without_attr_vars", 2) => Some(SystemClauseType::CopyTermWithoutAttrVars),

View File

@@ -1376,6 +1376,9 @@ impl MachineState {
&SystemClauseType::TruncateIfNoLiftedHeapGrowth => { &SystemClauseType::TruncateIfNoLiftedHeapGrowth => {
self.truncate_if_no_lifted_heap_diff(|_| Addr::Con(Constant::EmptyList)) self.truncate_if_no_lifted_heap_diff(|_| Addr::Con(Constant::EmptyList))
} }
&SystemClauseType::ClearAttributeGoals => {
self.attr_var_init.attribute_goals.clear();
}
&SystemClauseType::CloneAttributeGoals => { &SystemClauseType::CloneAttributeGoals => {
let attr_goals = self.attr_var_init.attribute_goals.clone(); let attr_goals = self.attr_var_init.attribute_goals.clone();
self.fetch_attribute_goals(attr_goals); self.fetch_attribute_goals(attr_goals);

View File

@@ -44,7 +44,9 @@
), ),
( '$get_b_value'(B), call(Term), '$write_eqs_and_read_input'(B, VarList), ( '$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) :- '$needs_bracketing'(Value, Op) :-
@@ -144,7 +146,7 @@
). ).
'$gather_query_vars'([], []). '$gather_query_vars'([], []).
'$is_a_different_variable'([Var = Binding | Pairs], Value) :- '$is_a_different_variable'([_ = Binding | Pairs], Value) :-
( Value == Binding, ! ( Value == Binding, !
; '$is_a_different_variable'(Pairs, Value) ; '$is_a_different_variable'(Pairs, Value)
). ).