Skip to content

Commit 899f282

Browse files
committed
Fixed issue 16.
- Use prolog_load_context module for tilde expansion if term being expanded is not qualified. - Added a passing test case.
1 parent 22772c5 commit 899f282

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

prolog/func.pl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,12 @@
180180

181181
% support foo(x,~,y) evaluation
182182
user:function_expansion(MTerm, Output, M:Goal) :-
183-
strip_module(MTerm, M, Term),
183+
(MTerm = M:Term ->
184+
true
185+
; % not module qualified ->
186+
prolog_load_context(module, M),
187+
Term = MTerm
188+
),
184189
wants_func,
185190
compound(Term),
186191

t/apply.pl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
:- use_module(library(func)).
2+
3+
:- prolog_load_context(directory, Dir),
4+
asserta(user:file_search_path(here, Dir)).
5+
26
:- use_module(library(tap)).
37

48
single :-
@@ -36,9 +40,10 @@
3640
asserta(my_mod:foo([1,2,3])),
3741
length(my_mod:foo(~), 3).
3842

39-
tilde_with_unqual_module(todo(issue_16)) :-
40-
use_module(foo),
41-
foo:bar(a).
43+
% see issue 16
44+
tilde_with_unqual_module :-
45+
use_module(here(resources/foo)), %% see dummy file resources/foo.pl
46+
foo:bar(a).
4247

4348
dicts :-
4449
John = person{ name: "John", age: 27 },
File renamed without changes.

0 commit comments

Comments
 (0)