Skip to content

Commit

Permalink
resolve panic caused by lingering attribute goals (#253)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Thom committed Dec 6, 2019
1 parent 90e1c99 commit 5ccd334
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/prolog/clause_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ pub enum SystemClauseType {
CharCode,
CharsToNumber,
ClearAttrVarBindings,
ClearAttributeGoals,
CloneAttributeGoals,
CodesToNumber,
CopyTermWithoutAttrVars,
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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),
Expand Down
3 changes: 3 additions & 0 deletions src/prolog/machine/system_calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions src/prolog/toplevel.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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) :-
Expand Down Expand Up @@ -144,7 +146,7 @@
).
'$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)
).
Expand Down

0 comments on commit 5ccd334

Please sign in to comment.