On Tuesday, March 5, 2013 8:19:01 AM UTC-5, Jan Mercl wrote:
if U cannot be assigned to T then the correct message is "Cannot
assign U to T". There is an unbound number of such U's and T's so
treating one particular pair specially is opening a can of worms.
Yes, that's true, and I'd be happy if it said something like that. For example, if it said:
"cannot use t.Time (Method) as type func() in function argument"
But it doesn't. It says:
"method t.Year is not an expression, must be called"
There's two possible reasons for someone writing t.Year:
- It's a simple syntax error (forgetting the parentheses) which is relatively unlikely and pretty obvious when looking at the code
- They're trying to pass the method as a function (a not uncommon newbie error), which is a significantly more complex error to understand.
The compiler currently assumes the reason is the first one, and complains about that.... but it is by far the easier error to see and fix... evidenced by the fact that you don't see long threads about how to fix missing parentheses in function calls.
Any error message for case #1 that mentions t.Year at all would be enough to tell but the most neophyte coder how to fix the code, if all they were missing was the parentheses.
So, if you have to pick one message to show, why not the one that works relatively well for #1, and is not completely useless for #2?