roc icon indicating copy to clipboard operation
roc copied to clipboard

bug: comments not accepted in REPL

Open gvwilson opened this issue 1 year ago • 4 comments

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".

» 

gvwilson avatar Mar 11 '24 00:03 gvwilson

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?

Anton-4 avatar Mar 11 '24 12:03 Anton-4

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.)

gvwilson avatar Mar 11 '24 14:03 gvwilson

"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.

Anton-4 avatar Mar 11 '24 15:03 Anton-4

#6574

Anton-4 avatar Mar 11 '24 15:03 Anton-4

Completed by https://github.com/roc-lang/roc/pull/6767

skyqrose avatar Nov 23 '24 19:11 skyqrose