From 290cb1b5171306d0c9275cdb12be9cb6d85b08cd Mon Sep 17 00:00:00 2001 From: Mark Thom Date: Tue, 23 Mar 2021 12:37:43 -0600 Subject: [PATCH] make retract_local_clauses safe, remove warning about overwriting warning in do_not_duplicate_path_components test --- src/machine/load_state.rs | 20 +++++++++++--------- tests/scryer/issues.rs | 1 - 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/machine/load_state.rs b/src/machine/load_state.rs index d0754936..e59d4a2a 100644 --- a/src/machine/load_state.rs +++ b/src/machine/load_state.rs @@ -344,7 +344,7 @@ impl<'a> LoadState<'a> { key: PredicateKey, clause_locs: &SliceDeque, ) { - let (clause_target_poses, is_dynamic) = self + let result_opt = self .wam .indices .get_predicate_skeleton(&compilation_target, &key) @@ -358,14 +358,16 @@ impl<'a> LoadState<'a> { }) .collect(), skeleton.is_dynamic) - }).unwrap(); - - self.retract_local_clauses_by_locs( - compilation_target, - key, - clause_target_poses, - is_dynamic, - ); + }); + + if let Some((clause_target_poses, is_dynamic)) = result_opt { + self.retract_local_clauses_by_locs( + compilation_target, + key, + clause_target_poses, + is_dynamic, + ); + } } pub(super) fn retract_local_clauses_by_locs( diff --git a/tests/scryer/issues.rs b/tests/scryer/issues.rs index 72f67194..7823cf43 100644 --- a/tests/scryer/issues.rs +++ b/tests/scryer/issues.rs @@ -29,7 +29,6 @@ fn do_not_duplicate_path_components() { "\ caught: e\n\ false.\n\ - Warning: overwriting $initialization_goals/1\n\ caught: e\n\ false.\n\ ", -- 2.54.0