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

Display multiline error message #252

Closed GreasySlug closed 1 year ago

GreasySlug commented 1 year ago

Fixes #248.

The REPL was taking out only the last line, even in the case of a multi-line error, so a blank space was displayed.

When a block is expected, ln_begin and ln_end of Range are different, so I used that to display

@mtshiba

GreasySlug commented 1 year ago
>>> for! 0..<4, i ->
...    print! i
... 
Error[#0340]: File <stdin>, line 2, ::stdin::<lambda>

2 |    print! i
  :    --------

this expression causes a side-effect
mtshiba commented 1 year ago
>>> while False, do!:
>>>    print! 1

gets

Error[#0361]: File <stdin>, line 1, <module>

1 |
  : -----
  :     `- exists a similar name variable: while!

while is not defined
GreasySlug commented 1 year ago

I realized that the problem has deeper roots than I thought. So I'll fix #58 first and then work on this issue.