- Code: Select all
class Program
def main
.method<int>(14)
def method<of T>(argument as T)
pass
Forums
Nonsensical error message when omitting 'of'
7 posts
• Page 1 of 1
Nonsensical error message when omitting 'of'
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.
- Chasm
- Posts: 33
Re: Nonsensical error message when omitting 'of'
Unfortunately contrary to your expectations this
is not just a wrongly specified collapsed generic call
( correctly specified would be
)
but is also instead a valid boolean expression (a ChainedCompareExpression)
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...
.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: 632
- Location: New Plymouth, Taranaki, New Zealand
Re: Nonsensical error message when omitting 'of'
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'
It is a little bit obscure. (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)
( 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: 632
- Location: New Plymouth, Taranaki, New Zealand
Re: Nonsensical error message when omitting 'of'
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.
Sometimes I think programming languages would be better off requiring a space around binary operators such as comparisons, arithmetic, etc.
- Charles
- Posts: 2515
- Location: Los Angeles, CA
Re: Nonsensical error message when omitting 'of'
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'
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.
- basmith
- Posts: 6
7 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 24 guests