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

Cannot be declared variables #276

Closed GreasySlug closed 1 year ago

GreasySlug commented 1 year ago

Describe the bug?

I want to declare mutable variables using !, but panic occurs.

Reproducible code

>>> a = !1

Expected result

No error

Actual result

[DEBUG] compiler\erg_compiler\codegen.rs:0639: entered emit_load_name_instr(.Int(: Untyped))
[DEBUG] compiler\erg_compiler\codegen.rs:0684: entered emit_import_name_instr(._erg_std_prelude(: Untyped))
[DEBUG] compiler\erg_compiler\codegen.rs:0696: entered emit_import_from_instr
[DEBUG] compiler\erg_compiler\codegen.rs:0805: entered emit_store_global_instr (::#mutate_operator(: Untyped))
[DEBUG] compiler\erg_compiler\codegen.rs:0639: entered emit_load_name_instr(::#mutate_operator(: Untyped))
[DEBUG] compiler\erg_compiler\codegen.rs:2360: entered emit_expr (1 (: {Nat(1), }))
[DEBUG] compiler\erg_compiler\codegen.rs:0639: entered emit_load_name_instr(.Nat(: Untyped))
[DEBUG] compiler\erg_compiler\codegen.rs:0781: entered emit_store_instr (::a(: Nat!))
thread '<unnamed>' panicked at 'not yet implemented: unknown opcode: 166', compiler\erg_common\opcode310.rs:10:1
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
current block: The REPL server is closed.
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Any { .. }', src\main.rs:72:22
error: process didn't exit successfully: `target\debug\erg.exe` (exit code: 101)

Additional context

Set type maybe different from other errors.

[DEBUG] compiler\erg_parser\desugar.rs:0053: the desugaring process has completed.
[DEBUG] compiler\erg_compiler\lower.rs:2055: the AST lowering process has started.
[DEBUG] compiler\erg_compiler\lower.rs:2056: the type-checking process has started.
[DEBUG] compiler\erg_compiler\reorder.rs:0032: the reordering process has started.
[DEBUG] compiler\erg_compiler\reorder.rs:0098: the reordering process has completed:
::a =
    `!`:
        {
            1
            2
        }
thread '<unnamed>' panicked at 'not yet implemented: {
    1
    2
}', compiler\erg_compiler\context\eval.rs:507:22
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
The REPL server is closed.

Erg version

Erg 0.6.0-beta.0

Python version

python3.10.8

OS

Windows 10

mtshiba commented 1 year ago

This does not reproduce in 0.6.0-beta.1.

Did you enter any other codes just before?

GreasySlug commented 1 year ago

Looking at the error code here, I think the error occurs in python 3.10.x version?

thread '<unnamed>' panicked at 'not yet implemented: unknown opcode: 166', compiler\erg_common\opcode310.rs:10:1

In fact, my python version is 3.10.8 and when I changed it to 3.11.0, the error did not occur.