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

Use `Del` to muttable variables cause panick in REPL #261

Closed GreasySlug closed 1 year ago

GreasySlug commented 1 year ago

Describe the bug?

This cannot be reproduced by the script It seems to be a REPL specific error Using ! to make a variable variable and then using Del to delete it will cause panic

Reproducible code

Not only Nat! type but also Int! etc. cause panic

>>> a = !1

>>> Del a

Expected result

No error

Actual result

[DEBUG] compiler\erg_compiler\context\inquire.rs:1283: Found:
callee: ::Del(: (obj: Obj) -> NoneType)
found: VarInfo{t: (obj: Obj) -> NoneType, muty: Immutable, vis: Private, kind: DoesNotExist, py_name: None}     
[DEBUG] compiler\erg_compiler\context\inquire.rs:1288: Instantiated:
instance: (obj: Obj) -> NoneType
pos_args: (::a(: Nat!))
kw_args: ()
[DEBUG] compiler\erg_compiler\context\tyvar.rs:1265: trying sub_unify:
maybe_sub: Nat!
maybe_sup: Obj
[DEBUG] compiler\erg_compiler\context\inquire.rs:1294: Substituted:
instance: (obj: Obj) -> NoneType
[DEBUG] compiler\erg_compiler\context\inquire.rs:1296: Params evaluated:
res: (obj: Obj) -> NoneType

[DEBUG] compiler\erg_compiler\context\inquire.rs:1298: Propagated:
res: (obj: Obj) -> NoneType

[DEBUG] compiler\erg_compiler\lower.rs:1924: HIR (not resolved, current errs: 0):
(::Del(: (obj: Obj) -> NoneType))
:
    ::a(: Nat!)
[DEBUG] compiler\erg_compiler\lower.rs:1927: HIR (resolved):
(::Del(: (obj: Obj) -> NoneType))
:
    ::a(: Nat!)
[DEBUG] compiler\erg_compiler\lower.rs:1947: the AST lowering process has completed.
[DEBUG] compiler\erg_compiler\effectcheck.rs:0089: the side-effects checking process has started.
[DEBUG] compiler\erg_compiler\effectcheck.rs:0189: the side-effects checking process has completed, found errors: 0
[DEBUG] compiler\erg_compiler\ownercheck.rs:0069: the ownership checking process has started.
[DEBUG] compiler\erg_compiler\ownercheck.rs:0298: drop: ::a(: Nat!) (in 1)
thread '<unnamed>' panicked at 'variable not found: ::a(: Nat!)', compiler\erg_compiler\ownercheck.rs:307:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
The REPL server is closed.
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Any { .. }', src\main.rs:68:22
error: process didn't exit successfully: `target\debug\erg.exe` (exit code: 101)

Additional context

No response

Erg version

0.5.13

Python version

python3.10.8

OS

Windows 10