ceylon / ceylon-spec

DEPRECATED
Apache License 2.0
108 stars 34 forks source link

Improve error message for function param type inference #1420

Open FroMage opened 9 years ago

FroMage commented 9 years ago

The following call:

    print(textFile.filter((line) => line.contains("Ceylon")).count());

Where filter does not accept a Callable, produces the following errors:

test.ceylon:35: error: parameter declaration does not exist: 'line'
    print(textFile.filter((line) => line.contains("Ceylon")).count());
                           ^
test.ceylon:35: error: function or value does not exist: 'line'
    print(textFile.filter((line) => line.contains("Ceylon")).count());
                                    ^
test.ceylon:35: error: function or value does not exist: 'line'
    print(textFile.filter((line) => line.contains("Ceylon")).count());
                                    ^

I'd really find the first one to be a lot clearer if it said something like cannot infer parameter type: left-hand-side does not accept functions: TextFile.filter. Although left-hand-side may still be too cryptic for users but I can't think of a better term ATM.

Also, I'm pretty sure we should get rid of the duplicate (third) error.

gavinking commented 9 years ago

I already did some work on this in @77b9dcca41f97af7ace80eca32d409efcc5c298b

FroMage commented 9 years ago

OK, that's better. But is there no way to explain why it can't be inferred? At least pointing to the expected type Function would help.