| Did you know ... | Search Documentation: |
| Pack starlog -- FINDALL_FIX_SUMMARY.md |
Fix all combinations and configurations of:
starlog_output_code(findall(X, (member(X, [1,2,3]), X > 1), Result),C), starlog_call(C).
The issue occurred when trying to generate Starlog code from a findall/3 call and then execute it:
'$VAR' terms. These renamed variables couldn't be unified when the generated code was passed to starlog_call/1.Added a special case in compile_starlog_expr/3 before the general value-returning builtin clause:
compile_starlog_expr(findall(Template, Goal), Out, Goals) :-
!,
expand_goal_internal(Goal, ExpandedGoal),
Goals = [findall(Template, ExpandedGoal, Out)].
This ensures:
Added a rename(true/false) option to starlog_output_code/3:
% Default behavior: % - rename(true) when print(true) - for display purposes % - rename(false) when print(false) - for execution purposes
This allows generated code to be executed while maintaining readable output when printing.
Added a guard clause in strip_eval_no_eval/4:
strip_eval_no_eval(Term, _StripEval, _StripNoEval, Term) :-
var(Term),
!.
This prevents infinite recursion when processing unbound variables.
Created tests/test_findall_output_code.pl with 12 tests covering:
✅ All 12 new tests pass ✅ All existing tests pass (test_basic, test_output_code, test_find, test_nested_functions, etc.) ✅ No regressions introduced
?- starlog_output_code(findall(X, (member(X, [1,2,3]), X > 1), Result), C), starlog_call(C). Result = [2,3].
?- starlog_output_code(
findall(X, member(X, [a,b,c]), Result),
C,
[compress(true), print(false), rename(false)]
),
starlog_call(C).
Result = [a,b,c].
?- starlog_output_code(
findall([A,B], (member(A, [1,2]), B is A*2), Result),
C
),
starlog_call(C).
Result = [[1,2], [2,4]].
starlog_expand.pl: Added special handling for findallstarlog.pl: Added rename option, variable guard, refactored for claritytests/test_findall_output_code.pl: New comprehensive test suiteThis fix enables proper round-tripping of findall predicates through starlog_output_code and starlog_call, allowing developers to: