bug: comments not accepted in REPL
On MacOS 14.3.1 using roc_nightly-macos_apple_silicon-2024-02-27-3ea97398f5, it appears that comments are not accepted by roc repl:
$ roc repl
The rockin' roc repl
────────────────────────
Enter an expression, or :help, or :q to quit.
» value = 123
123 : Num *
» # this is a comment
…
── MISSING EXPRESSION ──────────────────────────────────────────────────────────
I am partway through parsing a definition, but I got stuck here:
1│ app "app" provides [replOutput] to "./platform"
2│
3│ value = 123
4│
5│ replOutput =
6│ # this is a comment
7│
^
I was expecting to see an expression like 42 or "hello".
»
Thanks for reporting @gvwilson!
We currently request an additional line (with the …) after a comment. Would your desired behavior be to just print an empty prompt again » in the case of a comment followed by a double enter?
My apologies, but I'm still puzzled: if I run roc repl and the first line I enter is # comment <return> I get the … prompt. If I press <return> again I get the error message; if I try <space><nl> I get the same error message, and if I enter another comment line it just delays the problem. What should I enter to satisfy your request for another line?
(I'm comparing this with e.g. the Python REPL, where a line starting with # is ignored and the REPL immediately looks for more input.)
"the … prompt" is the request for another line, so you can do:
» # hello
… "Hey"
…
"Hey" : Str
I've checked some other languages too and they all follow the python behavior, so I'm good with that approach. I'll make a new issue for that.
#6574
Completed by https://github.com/roc-lang/roc/pull/6767