improve goal expansion and (',') interpretation error handling
This commit is contained in:
@@ -334,6 +334,9 @@ dispatch_prep(Gs, B, [Cont|Conts]) :-
|
|||||||
; Gs0 == ! ->
|
; Gs0 == ! ->
|
||||||
Cont = '$call'(builtins:set_cp(B)),
|
Cont = '$call'(builtins:set_cp(B)),
|
||||||
Conts = []
|
Conts = []
|
||||||
|
; nonvar(Gs0),
|
||||||
|
\+ callable(Gs0) ->
|
||||||
|
throw(dispatch_prep_error)
|
||||||
; Cont = Gs,
|
; Cont = Gs,
|
||||||
Conts = []
|
Conts = []
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -274,6 +274,13 @@ module_expanded_head_variables(Head, HeadVars) :-
|
|||||||
).
|
).
|
||||||
|
|
||||||
|
|
||||||
|
print_goal_expansion_warning(Pred) :-
|
||||||
|
nl,
|
||||||
|
write('Warning: clause body goal expansion failed because '),
|
||||||
|
writeq(Pred),
|
||||||
|
write(' is not callable.'),
|
||||||
|
nl.
|
||||||
|
|
||||||
expand_term_goals(Terms0, Terms) :-
|
expand_term_goals(Terms0, Terms) :-
|
||||||
( Terms0 = (Head1 :- Body0) ->
|
( Terms0 = (Head1 :- Body0) ->
|
||||||
( var(Head1) ->
|
( var(Head1) ->
|
||||||
@@ -282,13 +289,21 @@ expand_term_goals(Terms0, Terms) :-
|
|||||||
( atom(Module) ->
|
( atom(Module) ->
|
||||||
prolog_load_context(module, Target),
|
prolog_load_context(module, Target),
|
||||||
module_expanded_head_variables(Head2, HeadVars),
|
module_expanded_head_variables(Head2, HeadVars),
|
||||||
expand_goal(Body0, Target, Body1, HeadVars),
|
catch(expand_goal(Body0, Target, Body1, HeadVars),
|
||||||
|
error(type_error(callable, Pred), _),
|
||||||
|
( loader:print_goal_expansion_warning(Pred),
|
||||||
|
builtins:(Body1 = Body0)
|
||||||
|
)),
|
||||||
Terms = (Module:Head2 :- Body1)
|
Terms = (Module:Head2 :- Body1)
|
||||||
; type_error(atom, Module, load/1)
|
; type_error(atom, Module, load/1)
|
||||||
)
|
)
|
||||||
; module_expanded_head_variables(Head1, HeadVars),
|
; module_expanded_head_variables(Head1, HeadVars),
|
||||||
prolog_load_context(module, Target),
|
prolog_load_context(module, Target),
|
||||||
expand_goal(Body0, Target, Body1, HeadVars),
|
catch(expand_goal(Body0, Target, Body1, HeadVars),
|
||||||
|
error(type_error(callable, Pred), _),
|
||||||
|
( loader:print_goal_expansion_warning(Pred),
|
||||||
|
builtins:(Body1 = Body0)
|
||||||
|
)),
|
||||||
Terms = (Head1 :- Body1)
|
Terms = (Head1 :- Body1)
|
||||||
)
|
)
|
||||||
; Terms = Terms0
|
; Terms = Terms0
|
||||||
@@ -688,7 +703,10 @@ expand_subgoal(UnexpandedGoals, MS, M, ExpandedGoals, HeadVars) :-
|
|||||||
|
|
||||||
expand_module_name(ESG0, MS, M, ESG) :-
|
expand_module_name(ESG0, MS, M, ESG) :-
|
||||||
( var(ESG0) ->
|
( var(ESG0) ->
|
||||||
ESG = M:ESG0
|
( M == user ->
|
||||||
|
ESG = ESG0
|
||||||
|
; ESG = M:ESG0
|
||||||
|
)
|
||||||
; ESG0 = _:_ ->
|
; ESG0 = _:_ ->
|
||||||
ESG = ESG0
|
ESG = ESG0
|
||||||
; functor(ESG0, F, A0),
|
; functor(ESG0, F, A0),
|
||||||
@@ -753,7 +771,6 @@ expand_module_names(Goals, MetaSpecs, Module, ExpandedGoals, HeadVars) :-
|
|||||||
).
|
).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
:- non_counted_backtracking expand_goal/3.
|
:- non_counted_backtracking expand_goal/3.
|
||||||
|
|
||||||
expand_goal(UnexpandedGoals, Module, ExpandedGoals) :-
|
expand_goal(UnexpandedGoals, Module, ExpandedGoals) :-
|
||||||
|
|||||||
Reference in New Issue
Block a user