% -*- mode: Prolog -*-

:- use_module(library(edcg)).

?- current_prolog_flag(version, PrologVersion),
   (   PrologVersion >= 80319
   ->  true
   ;   throw('SWI-Prolog version is too old':PrologVersion)
   ).
?- pack_property(edcg, version(EdcgVersion)),
   (   EdcgVersion @>= '0.9.1.5'
   ->  true
   ;   throw('pack(edcg) is missing or version is too old':EdcgVersion)
   ).

:- meta_predicate maplist_kyfact_symrej(7, +, -, +, -, +, -, +).  % <==== REMOVING THIS FIXES THE PROBLEM.

edcg:acc_info(kyfact, T, Out, In, Out=[T|In]).
edcg:acc_info(expr, T, Out, In, Out=[T|In]).
edcg:acc_info(symrej, FqnType, In, Out, symrej_accum(FqnType, In, Out)).
edcg:pass_info(file_meta).

edcg:pred_info(kyanchor_binding, 6,                [kyfact,file_meta]).
edcg:pred_info(maplist_kyfact_symrej, 3,           [kyfact,symrej,file_meta]).
edcg:pred_info(eval_assign_dot_op_binds_single, 4, [kyfact,symrej,file_meta]).
edcg:pred_info(eval_union_type, 2,                 [kyfact,symrej,file_meta]).

eval_assign_dot_op_binds_single(RightEval, astn(Start,End,AttrName), _BindsLeft, function_type(FunctionName,Params, Return)) ==>>
    % TODO: use builtins.function's definition, if it exists,
    %       otherwise allow adding a new attr.
    eval_union_type(Return, _),
    maplist_kyfact_symrej(eval_union_type, Params, _),
    { join_fqn([FunctionName, AttrName], BindsFqn) },
    [ BindsFqn-RightEval-_ ]:symrej,
    kyanchor_binding(Start,End, AttrName, BindsFqn, FunctionName, 'eval_assign_dot_op_binds_single/function_type').

?- format('=================~n').
?- format('=====listing=====~n').
?- listing(eval_assign_dot_op_binds_single).
