Problem with incompatible types

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

Problem with incompatible types

Post by Martin Meyer » 2 Sep 2017 13:14

Hello Thomas,

please have a look at below stripped down version of my code. It throws error c504 : The expression has type 'syntax_t_nt::grammarSymbol{::unsigned, ::unsigned}', which is incompatible with the type 'syntax_t_nt::grammarSymbol{@Terminal, @Nonterminal}' in VIP 8.0.0. How can I circumvent the problem?

Code: Select all

interface syntax_t_nt{@Terminal, @Nonterminal}   domains     grammarSymbol =         t(@Terminal T);         nt(@Nonterminal Nt).     grammarString = grammarSymbol*.   end interface syntax_t_nt   %======   interface cfg{@Terminal, @Nonterminal}     open syntax_t_nt{@Terminal, @Nonterminal}   predicates     isNullable : (grammarString GrmStrg) determ.   end interface cfg   %======   interface cfgSupportSite{@Terminal, @Nonterminal}   predicates from cfg{@Terminal, @Nonterminal}     isNullable/1   end interface cfgSupportSite   %======   class unsignedCfg : cfg{unsigned, unsigned} end class unsignedCfg   %---   implement unsignedCfg     open syntax_t_nt{unsigned, unsigned}     supports cfgSupportSite{unsigned, unsigned}   clauses     isNullable([nt(Nt) | RestGrmStrg]) :- %the error refers to nt(Nt) in this line         doSomethingWithAnUnsigned(Nt),         isNullable(RestGrmStrg).       isNullable([]).   predicates     doSomethingWithAnUnsigned : (unsigned). clauses     doSomethingWithAnUnsigned(_).   end implement unsignedCfg   %======   implement main   clauses     run() :-         _ = unsignedCfg::new().   end implement main
Regards Martin

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

Post by Thomas Linder Puls » 4 Sep 2017 9:53

In this particular case a workaround is not to use open in the cfg interface:

Code: Select all

 
We will of course look for a non-workaround solution as well.
Regards Thomas Linder Puls
PDC

Martin Meyer
VIP Member
Posts: 241
Joined: 14 Nov 2002 0:01

Post by Martin Meyer » 4 Sep 2017 17:38

Thank you! I followed your advice and it works now.
Regards Martin

Post Reply