erg-lang / erg

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

Using a variable that caused an error causes panic #272

Closed GreasySlug closed 1 year ago

GreasySlug commented 1 year ago

Describe the bug?

In REPL, assigning code to a variable that causes a syntax or compile error Using the assigned variable causes a panic

Reproducible code

>>> a = sample
Error[#0391]: File <stdin>, line 1, <module>::a

1 | a = sample
  :     ------

sample is not defined

>>> a

Expected result

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

1 | a
  : -

a is not defined

Actual result

panic

Traceback (most recent call last):
  File "<string>", line 28, in <module>
  File "<string>", line 1, in <module>
  File "<stdin>", line -1, in <module>
NameError: name '::a' is not defined

During handling of the above exception, another exception occurred:   

Traceback (most recent call last):
  File "<string>", line 32, in <module>
NameError: name 'e' is not defined
>>>
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` 
value: Os { code: 10053, kind: ConnectionAborted, message: "確立された
接続がホスト コンピューターのソウトウェアによって中止されました。" }', src\dummy.rs:93:49
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` 
value: Os { code: 10053, kind: ConnectionAborted, message: "確立された
接続がホスト コンピューターのソウトウェアによって中止されました。" }', src\dummy.rs:93:49
stack backtrace:

Additional context

No response

Erg version

0.5.13

Python version

python3.10.8

OS

Windows 10