Page 1 of 1

Nonsensical error message when omitting 'of'

PostPosted: Fri Jun 28, 2013 6:01 am
by Chasm
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

Re: Nonsensical error message when omitting 'of'

PostPosted: Tue Jul 02, 2013 5:46 am
by hopscc
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...

Re: Nonsensical error message when omitting 'of'

PostPosted: Tue Jul 02, 2013 6:13 am
by Chasm
Writing parsers really must be a hassle, I didn't even see this other possibility.

Re: Nonsensical error message when omitting 'of'

PostPosted: Tue Jul 02, 2013 6:32 am
by hopscc
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)

Re: Nonsensical error message when omitting 'of'

PostPosted: Tue Jul 02, 2013 1:53 pm
by Charles
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.

Re: Nonsensical error message when omitting 'of'

PostPosted: Tue Jul 02, 2013 3:03 pm
by Chasm
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.

Re: Nonsensical error message when omitting 'of'

PostPosted: Wed Jul 03, 2013 5:58 am
by basmith
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: