elm / error-message-catalog

A catalog of broken Elm programs / data to improve error messages
BSD 3-Clause "New" or "Revised" License
173 stars 17 forks source link

Unhelpful compiler error message: "and" should suggest "&&" #298

Open skyqrose opened 5 years ago

skyqrose commented 5 years ago

Quick Summary:

When trying to compile code with and, the compiler does not give any suggestion to use && instead.

It gives this unhelpful error message:

naming error
Line 21, Column 12
I cannot find a `and` variable:

21|     , True and True
               ^^^
These names seem close though:

    abs
    tan
    acos
    asin

Hint: Read <https://elm-lang.org/0.19.0/imports> to see how `import`
declarations work in Elm.

Expected: there would be some hint to use && instead. For example, when using & there is a helpful error message:

unknown operator
Line 22, Column 12
I do not recognize the (&) operator.

22|     , True & True
               ^
Is there an `import` and `exposing` entry for it? Maybe you want (&&) or (*)
instead?

An even better example is the excellent explanation given when trying to use != instead of /=

unknown operator
Line 23, Column 12
Elm uses a different name for the “not equal” operator:

23|     , True != True
               ^^
Switch to (/=) instead.

Note: Our (/=) operator is supposed to look like a real “not equal” sign (≠). I
hope that history will remember (!=) as a weird and temporary choice.

Same goes for | suggesting ||, but or giving an unhelpful error.

Ellie showing these error messages