Forums

Nonsensical error message when omitting 'of'

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

Nonsensical error message when omitting 'of'

Postby Chasm » Fri Jun 28, 2013 6:01 am

The following code produced this error message "The method "method" is expecting 1 argument, but no arguments are being supplied in this call. The declaration is "method(argument as T)"". I would expect an error like "Incorrect type specified "method<int>". Did you mean "method<of int>"?" I don't know, something like that.
Code: Select all
class Program

    def main
        .method<int>(14)

    def method<of T>(argument as T)
        pass
Chasm
 
Posts: 33

Re: Nonsensical error message when omitting 'of'

Postby hopscc » Tue Jul 02, 2013 5:46 am

Unfortunately contrary to your expectations this
.method<int>(14)

is not just a wrongly specified collapsed generic call
( correctly specified would be
.method<of int>(14)

)

but is also instead a valid boolean expression (a ChainedCompareExpression)
#like 1 < a < 20
# a between 1 and 19

#as in
.method < int > (14)
# or
#.method < id > 14 # id > .method() and id > 12


It (correctly) errors cos of a mismatch on the call to method signature ( as indicated - no arg)
If thats corrected it fails on the comparison of method return type vs Type (int)

Still - it is confusing...
hopscc
 
Posts: 631
Location: New Plymouth, Taranaki, New Zealand

Re: Nonsensical error message when omitting 'of'

Postby Chasm » Tue Jul 02, 2013 6:13 am

Writing parsers really must be a hassle, I didn't even see this other possibility.
Chasm
 
Posts: 33

Re: Nonsensical error message when omitting 'of'

Postby hopscc » Tue Jul 02, 2013 6:32 am

It is a little bit obscure. :o (The chainedCompare capability)

( To be honest neither did I till I started to looking why the param checking code was outputting that message just there - thought there was a bug in that code...).

Its a bit surprising and a possibly easy enough error to make for ones coming from C*/Java.

I'm just testing a patch to trap that and output something a bit more informative. (ticket:337)
hopscc
 
Posts: 631
Location: New Plymouth, Taranaki, New Zealand

Re: Nonsensical error message when omitting 'of'

Postby Charles » Tue Jul 02, 2013 1:53 pm

Yeah, the type in the middle is a huge hint that something is amiss. :-)

Sometimes I think programming languages would be better off requiring a space around binary operators such as comparisons, arithmetic, etc.
Charles
 
Posts: 2510
Location: Los Angeles, CA

Re: Nonsensical error message when omitting 'of'

Postby Chasm » Tue Jul 02, 2013 3:03 pm

Charles wrote:Sometimes I think programming languages would be better off requiring a space around binary operators such as comparisons, arithmetic, etc.


I know you were just 'kind of' saying this, but it would make the parser less complex, the code more standardized and the error generation actually useful. Just a thought.
Chasm
 
Posts: 33

Re: Nonsensical error message when omitting 'of'

Postby basmith » Wed Jul 03, 2013 5:58 am

Charles wrote:Sometimes I think programming languages would be better off requiring a space around binary operators such as comparisons, arithmetic, etc.


The upside is that would allow for hyphenated identifiers, which has always been a secret desire of mine. :oops:
basmith
 
Posts: 6


Return to Discussion

Who is online

Users browsing this forum: No registered users and 3 guests

cron