Compiler error on anonymous predicate

Discussions related to Visual Prolog
Martin Meyer
VIP Member
Posts: 280
Joined: 14 Nov 2002 0:01

Compiler error on anonymous predicate

Unread post by Martin Meyer » 16 Sep 2013 10:51

Hi,

I suppose it's a bug, that the compiler throws error "The expression has type 'ast::astTree{@Token}', which is incompatible with the type '@Token'" on this:

Code: Select all

interface ast{@Token}     open core   domains     astTree = astTree(         symbol RuleName,         argumentAstTree* ArgAstTreeList).     argumentAstTree =         argAstTree(astTree AstTree);         argToken(@Token Tok).   predicates     containsToken : (         @Token Tok,         astTree AstTree)         determ (i, i).   predicates     containsTokenEq : (         @Token Tok,         astTree AstTree,         predicate_dt{@Token TokA, @Token TokB} TokEquivalent)         determ (i, i, i).   end interface ast   %===========   class ast{@Token} : ast{@Token} end class ast   %===========   implement ast{@Token}     open core   clauses     containsToken(Tok, AstTree):-         containsTokenEq(Tok, AstTree, {(T, T)}).   clauses     containsTokenEq(Tok, astTree(_, ArgAstTreeList), TokEquivalent):-         containsTokenEq_0(Tok, ArgAstTreeList, TokEquivalent).   predicates     containsTokenEq_0 : (         @Token Tok,         argumentAstTree* ArgAstTreeList,         predicate_dt{@Token TokA, @Token TokB} TokEquivalent)         determ (i, i, i). clauses     containsTokenEq_0(Tok, [ArgAstTree | _], TokEquivalent):-         containsTokenEq_1(Tok, ArgAstTree, TokEquivalent),         !.     containsTokenEq_0(Tok, [_ | ArgAstTreeRestList], TokEquivalent):-         containsTokenEq_0(Tok, ArgAstTreeRestList, TokEquivalent).   predicates     containsTokenEq_1 : (         @Token Tok,         argumentAstTree ArgAstTree,         predicate_dt{@Token TokA, @Token TokB} TokenEquivalent)         determ (i, i, i). clauses     containsTokenEq_1(Tok, argAstTree(AstTree), TokEquivalent):-         containsTokenEq(Tok, AstTree, TokEquivalent).     containsTokenEq_1(TokA, argToken(TokB), TokEquivalent):-         TokEquivalent(TokA, TokB).   end implement ast
But when I replace

Code: Select all

        {(T, T)}
by

Code: Select all

        {(TokA, TokB):- TokA = TokB}
then all works fine.

The problem disappears, when I try to simplify the example's code to:

Code: Select all

interface ast{@Token}     open core   predicates     containsToken : (         @Token TokA,         @Token TokB)         determ (i, i).   predicates     containsTokenEq : (         @Token TokA,         @Token TokB,         predicate_dt{@Token TokA, @Token TokB} TokEquivalent)         determ (i, i, i).   end interface ast   %===========   class ast{@Token} : ast{@Token} end class ast   %===========   implement ast{@Token}     open core   clauses     containsToken(TokA, TokB):-         containsTokenEq(TokA, TokB, {(T, T)}).   clauses     containsTokenEq(TokA, TokB, TokEquivalent):-         TokEquivalent(TokA, TokB).   end implement ast
Regards,
Martin

User avatar
Thomas Linder Puls
VIP Member
Posts: 1172
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls » 16 Sep 2013 14:54

Thank you, we will look at it.
Regards Thomas Linder Puls
PDC

Post Reply