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

Crash when trying to reference mutable variable in REPL #108

Closed mtshiba closed 2 years ago

mtshiba commented 2 years ago

Reproducible code

>>> i = !100
>>> i

Expected behavior

1

Result

[DEBUG] compiler\erg_compiler\compile.rs:0161: the compiling process has started
[DEBUG] compiler\erg_parser\parse.rs:0369: the parsing process has started.
[DEBUG] compiler\erg_parser\parse.rs:0370: token stream: [Symbol i, EOF ]
[DEBUG] compiler\erg_parser\parse.rs:0401:
  (1) entered try_reduce_module, cur: Symbol i
[DEBUG] compiler\erg_parser\parse.rs:1722:
   (2) entered try_reduce_expr, cur: Symbol i
[DEBUG] compiler\erg_parser\parse.rs:1866:
    (3) entered try_reduce_bin_lhs, cur: Symbol i
[DEBUG] compiler\erg_parser\parse.rs:1956:
     (4) entered try_reduce_call_or_acc, cur: Symbol i
[DEBUG] compiler\erg_parser\parse.rs:0665:
      (5) entered try_reduce_acc, cur: Symbol i
[DEBUG] compiler\erg_parser\parse.rs:0383: the parsing process has completed.
[DEBUG] compiler\erg_parser\parse.rs:0384: AST:
i
[DEBUG] compiler\erg_parser\parse.rs:0385: the desugaring process has started.
[DEBUG] compiler\erg_parser\parse.rs:0388: AST (desugared):
i
[DEBUG] compiler\erg_parser\parse.rs:0389: the desugaring process has completed.
[DEBUG] compiler\erg_compiler\lower.rs:0549: the AST lowering process has started.
[DEBUG] compiler\erg_compiler\lower.rs:0550: the type-checking process has started.
[DEBUG] compiler\erg_compiler\lower.rs:0522: entered lower_expr
[DEBUG] compiler\erg_compiler\lower.rs:0233: entered lower_acc(i)
[DEBUG] compiler\erg_compiler\lower.rs:0564: HIR (not derefed):
i (: Nat!)
[DEBUG] compiler\erg_compiler\lower.rs:0565: the type-checking process has completed, found errors: 0
[DEBUG] compiler\erg_compiler\lower.rs:0572: HIR:
i (: Nat!)
[DEBUG] compiler\erg_compiler\lower.rs:0573: the AST lowering process has completed.
[DEBUG] compiler\erg_compiler\effectcheck.rs:0080: the side-effects checking process has started.
[DEBUG] compiler\erg_compiler\effectcheck.rs:0106: the side-effects checking process has completed, found errors: 0
[DEBUG] compiler\erg_compiler\ownercheck.rs:0059: the ownership checking process has started.
[DEBUG] compiler\erg_compiler\ownercheck.rs:0191: drop: i (in 1)
thread 'main' panicked at 'variable not found: i', compiler\erg_compiler\ownercheck.rs:267:9
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/9067d5277d10f0f32a49ec9c125a33828e26a32b/library\std\src\panicking.rs:584
   1: core::panicking::panic_fmt
             at /rustc/9067d5277d10f0f32a49ec9c125a33828e26a32b/library\core\src\panicking.rs:142
   2: erg_compiler::ownercheck::OwnershipChecker::drop
             at .\compiler\erg_compiler\ownercheck.rs:267
   3: erg_compiler::ownercheck::OwnershipChecker::check_acc
             at .\compiler\erg_compiler\ownercheck.rs:196
   4: erg_compiler::ownercheck::OwnershipChecker::check_expr
             at .\compiler\erg_compiler\ownercheck.rs:98
   5: erg_compiler::ownercheck::OwnershipChecker::check
             at .\compiler\erg_compiler\ownercheck.rs:64
   6: erg_compiler::compile::Compiler::compile
             at .\compiler\erg_compiler\compile.rs:179
   7: erg_compiler::compile::Compiler::compile_and_dump_as_pyc<str>
             at .\compiler\erg_compiler\compile.rs:154
   8: erg::dummy::impl$0::eval
             at .\src\dummy.rs:101
   9: erg_common::traits::Runnable::run<erg::dummy::DummyVM>
             at .\compiler\erg_common\traits.rs:366
  10: erg::main
             at .\src\main.rs:32
  11: core::ops::function::FnOnce::call_once<void (*)(),tuple$<> >
             at /rustc/9067d5277d10f0f32a49ec9c125a33828e26a32b\library\core\src\ops\function.rs:248
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Traceback (most recent call last):
  File "<string>", line 18, in <module>
ConnectionAbortedError: [WinError 10053] 確立された接続がホスト コンピューターのソウトウェアによって中止されました。
error: process didn't exit successfully: `target\debug\erg.exe` (exit code: 101)