Forums

strangeness with _ methods returning bool - compile error

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

strangeness with _ methods returning bool - compile error

Postby hopscc » Wed Oct 29, 2008 11:44 pm

Heres something a bit strange
Code: Select all
class Funny
   
   def _isFunny as bool
      return true
      
   def z
      # below gives C# compile error: ... (9) error:Cannot convert method group "_isFunny" to non-delegate type "bool". Did you intend to invoke the method? (C#)
      if _isFunny
      #if _isFunny()   # if done like this compiles OK
         print 'OK'
         
   def main is shared
      x=Funny()
      if x._isFunny      # this is OK
         print 'isFunny'

Seems to only occur with noarg _ named methods returning bool when called from inside the class without appending explicit '()'
(thats where I noticed it anyway).
The generated c# code for the failing line is missing an added '()' on the call to isFunny.
Code: Select all
#line 9
      if (_isFunny) {
#line 11
         CobraImp.PrintLine(CobraImp._printStringMaker.MakeString("OK"));
#line 11
      }
#line 11

vs
Code: Select all
#line 15
         if (x._isFunny()) {
#line 16
            CobraImp.PrintLine(CobraImp._printStringMaker.MakeString("isFunny"));
#line 16
         }
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: strangeness with _ methods returning bool - compile error

Postby Charles » Thu Oct 30, 2008 9:19 am

I'll take a look later today.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: strangeness with _ methods returning bool - compile error

Postby Charles » Tue Nov 04, 2008 6:01 pm

Fixed in the repository.
Charles
 
Posts: 2515
Location: Los Angeles, CA


Return to Discussion

Who is online

Users browsing this forum: No registered users and 37 guests