From 8e405290237625f6dd1305c6be4062eebdc750a9 Mon Sep 17 00:00:00 2001 From: Eyal Dechter Date: Wed, 26 Oct 2016 22:17:42 -0400 Subject: [PATCH 1/4] Added failing test case for scope issue. --- t/apply.pl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/t/apply.pl b/t/apply.pl index d35b3f7..a8f5cde 100644 --- a/t/apply.pl +++ b/t/apply.pl @@ -45,6 +45,12 @@ use_module(here(resources/foo)), %% see dummy file resources/foo.pl foo:bar(a). +tilde_in_meta_predicate( + todo('bug: function expantion occurs outside meta_predicate scope') +) :- + findall(X, (Y = 1, X = succ(Y, ~)), Xs), + Xs == [2]. + dicts :- John = person{ name: "John", age: 27 }, "John" == John $ name, From 8c5a35359f8677c6aa3caf8042f97f73102f8772 Mon Sep 17 00:00:00 2001 From: Eyal Dechter Date: Thu, 27 Oct 2016 14:05:47 -0400 Subject: [PATCH 2/4] Test no longer fails --- t/apply.pl | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/t/apply.pl b/t/apply.pl index a8f5cde..fcf684b 100644 --- a/t/apply.pl +++ b/t/apply.pl @@ -45,9 +45,7 @@ use_module(here(resources/foo)), %% see dummy file resources/foo.pl foo:bar(a). -tilde_in_meta_predicate( - todo('bug: function expantion occurs outside meta_predicate scope') -) :- +tilde_in_meta_predicate :- findall(X, (Y = 1, X = succ(Y, ~)), Xs), Xs == [2]. From e42c014005b2466f9ffb8cdb5fbee258ad563585 Mon Sep 17 00:00:00 2001 From: Eyal Dechter Date: Thu, 27 Oct 2016 14:06:05 -0400 Subject: [PATCH 3/4] Added additional tests for meta predicates with ~ - bagof still doesn't work --- t/apply.pl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/t/apply.pl b/t/apply.pl index fcf684b..aa4ca39 100644 --- a/t/apply.pl +++ b/t/apply.pl @@ -57,3 +57,18 @@ 'dict missing a key'(fail) :- Point = point{x:2, y:3}, writeln(Point $ z). % looking up z fails + + +%% meta calls +succ(succ(call(succ, succ(1, ~), ~), ~), 5). + +append(append([a], [b], ~), [c], [a,b,c]). + +findall(X, (member(Y, [1,2]), X is 2 * succ(Y, ~)), [4, 6]). + +bagof(fixme('fails because of ^ meta arg spec is not supported')) :- + bagof(X, (member(Y, [1,2]), X is 2 * succ(Y, ~)), [4, 6]). + + + + From 58bab7969448e6c229250c2e5c43eedae2d6fbb5 Mon Sep 17 00:00:00 2001 From: Eyal Dechter Date: Thu, 27 Oct 2016 15:07:14 -0400 Subject: [PATCH 4/4] Added additional test --- t/apply.pl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/t/apply.pl b/t/apply.pl index aa4ca39..dcf97de 100644 --- a/t/apply.pl +++ b/t/apply.pl @@ -70,5 +70,13 @@ bagof(X, (member(Y, [1,2]), X is 2 * succ(Y, ~)), [4, 6]). +maplist_example :- maplist([X, Y]>>append(X, append([a], [b], ~), Y), + [[c], [d]], + [[c, a, b], + [d, a, b]]). + + + +