elm / error-message-catalog

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

somewhat unhelpful error message for missing `else` branch #195

Closed brainrake closed 5 years ago

brainrake commented 7 years ago
a = if True then 1

b = 2

Error message:

Detected errors in 1 module.

-- SYNTAX PROBLEM --------------------------------------------------------------

I need whitespace, but got stuck on what looks like a new declaration. You are
either missing some stuff in the declaration above or just need to add some
spaces here:

5| b = 2
   ^
I am looking for one of the following things:

    whitespace
kipanshi commented 7 years ago

Ubuntu 16.04 64bit, processor Core i7

I'm getting different error:

> over9000 powerLevel = \
|     if powerLevel > 9000 then "It's over 9000!"
-- SYNTAX PROBLEM -------------------------------------------- repl-temp-000.elm

The = operator is reserved for defining variables. Maybe you want == instead? Or
maybe you are defining a variable, but there is whitespace before it?
evancz commented 5 years ago

Thanks for the report! I am finishing up an overhaul of the parser that will produce nicer error messages, so my development build is now producing:

-- UNFINISHED IF ------------------------------------------------------ temp.elm

I was expecting to see an `else` branch after this:

1| a = if True then 1
                     ^
I know what to do when the condition is `True`, but not when it is `False`.

Add an else branch to handle that scenario!

Actually talks about needing an else branch now!