From 922895279eb090c1a63ddb35dfe4e7194865e8b1 Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Sun, 1 Jan 2023 22:17:22 +0200 Subject: [PATCH] FIXED: find next predicate definition more reliably * sweep.pl (sweeprolog_beginning_of_last_predicate/2) (sweeprolog_beginning_of_last_predicate/2): explicitly sort results, don't assume xref_defined/3 yields ordered results. --- sweep.pl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sweep.pl b/sweep.pl index 5b0b13b..f859eea 100644 --- a/sweep.pl +++ b/sweep.pl @@ -755,13 +755,19 @@ sweep_beginning_of_last_predicate(Start, Next) :- L < Start ), Ls), - reverse(Ls, [Next|_]). + sort(Ls, Sorted), + reverse(Sorted, [Next|_]). sweep_beginning_of_next_predicate(Start, Next) :- sweep_source_id(Path), xref_source(Path, [comments(store)]), - xref_defined(Path, _, H), xref_definition_line(H, Next), - Start < Next. + findall(L, + ( xref_defined(Path, _, H), + xref_definition_line(H, L), + Start < L + ), + Ls), + sort(Ls, [Next|_]). sweep_source_id(Path) :- sweep_main_thread, -- 2.39.2