elm-repl icon indicating copy to clipboard operation
elm-repl copied to clipboard

Better error message when \ is followed by space

Open evancz opened this issue 10 years ago • 6 comments

When typing in a multi-line value, where \ is used to request a line break, you can trigger an error by putting stuff after the /. Check out the very sneaky extra space in the following line:

> over9000 powerLevel = \ 

Python gives a relatively nice message when this mistake is made:

>>> 123 + 412 \ 
  File "<stdin>", line 1
    123 + 412 \ 
               ^
SyntaxError: unexpected character after line continuation character
>>> 

We should do something like that.

evancz avatar Oct 10 '15 00:10 evancz

this still doesn't work

no matter how I do the whitespace can't get this example to work in REPL http://elm-lang.org/guide/model-the-problem

longestName : List String -> Int
longestName names =
List.maximum (List.map String.length names)

anthonylouisburns avatar Dec 14 '15 02:12 anthonylouisburns

Brand new to Elm. Got this same issue while running through core language guide, then inserted a space like someone mentioned in #79 . At least partly, this issue may be confustion with the guide itself. The "over9000 powerLevel" example might be a good place to refer to indentation for the first time.

hogganbeck avatar Apr 13 '16 05:04 hogganbeck

Stumbled on this too, while following the Elm guide. Luckily the Elm slack #help was able to point out my whitespace error. Is the whitespace something that the repl could add where it knows things should be indented?

ShepBook avatar May 18 '16 07:05 ShepBook

Also got here because of "over9000 powerLevel" example. The REPL didn't complain until after I typed the continuing line without leading spaces (which I hadn't noticed in the example), so that should have been a clue, but I had seen the leading | which I took to mean "I know you're continuing a line", so it didn't occur to me that I needed to do anything else to confirm that. I agree that it should add the leading spaces in that case.

nathanl avatar May 27 '16 09:05 nathanl

@evancz, I have the similar problem on Windows 10, using Elm 0.17.1. To reproduce:

  • Enter "> over9000 powerLevel = " (there is not any space after slash) and then "| powerLevel";
  • Expected behaviour is to get the id function, but I got a syntax error with the message: "I am looking for one of the following things: end of input whitespace".

Karkunow avatar Aug 06 '16 00:08 Karkunow

Touples example is quite impossible to write in repl. Tried many times didn't manage as of yet ...

gor181 avatar Nov 13 '16 15:11 gor181