erg-lang / erg

A statically typed language compatible with Python
http://erg-lang.org
Apache License 2.0
2.69k stars 55 forks source link

In REPL, new line is not appropriately handled. #144

Closed ytoml closed 2 years ago

ytoml commented 2 years ago

Describe the bug In REPL, a new line is always evaluated immedately, and it prevent us from defining procedures/functions with multiple lines or method for classes.

Reproducible code

X = Class {.inner = Int}
X. # press enter here

we observe:

Error[#0000]: File <string>, line 1
1│ X.
     ^
SyntaxError: invalid syntax

Also, new lines just after = is respected:

>>> fib n =
...

but it's not respected with whitespaces:

>>> fib n ={some whitespaces}
Error[#0000]: File <string>, line 1
1│ fib n = 
           ^
SyntaxError: invalid syntax

Expected behavior REPL waits for next input in case new lines follows

ytoml commented 2 years ago

Actually I could fix it locally and now try to respect comment, I mean enabling:

fib n = # fibonnacci
...

I will open PR later.