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

Defining an empty tuple will cause panic #282

Closed GreasySlug closed 1 year ago

GreasySlug commented 1 year ago

Describe the bug?

Assigning an empty tuple to a variable will cause a panic

Reproducible code

a = ()

Expected result

No error

Actual result

[DEBUG] compiler\erg_compiler\lower.rs:2159: 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:0197: the side-effects checking process has completed, found errors: 0
[DEBUG] compiler\erg_compiler\ownercheck.rs:0071: the ownership checking process has started.
[DEBUG] compiler\erg_compiler\ownercheck.rs:0298: define: ::D(: Tuple([]))
[DEBUG] compiler\erg_compiler\ownercheck.rs:0080: [DEBUG] the ownership checking process has completed, found errors: 0
[DEBUG] compiler\erg_compiler\link.rs:0034: the linking process has started.
[DEBUG] compiler\erg_compiler\link.rs:0041: linked: ::D(: Tuple([])) =
    (

    )(: Tuple([]))
[DEBUG] compiler\erg_compiler\desugar_hir.rs:0011: HIR desugaring process has started.
[DEBUG] compiler\erg_compiler\desugar_hir.rs:0013: HIR desugaring process has completed.
[DEBUG] compiler\erg_compiler\codegen.rs:2892: the code-generating process has started.
[DEBUG] compiler\erg_compiler\codegen.rs:2367: entered emit_expr (::D(: Tuple([])) =
    (

    )(: Tuple([])))
[DEBUG] compiler\erg_compiler\codegen.rs:0912: entered emit_def (::D(: Tuple([])))
[DEBUG] compiler\erg_compiler\codegen.rs:1211: entered emit_var_def (::D(: Tuple([])) = (

)(: Tuple([])))
[DEBUG] compiler\erg_compiler\codegen.rs:2367: entered emit_expr ((

)(: Tuple([])))
thread '<unnamed>' panicked at '(

)(: Tuple([]))', compiler\erg_compiler\codegen.rs:2368:46
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:72:22
error: process didn't exit successfully: `target\debug\erg.exe` (exit code: 101)

Additional context

Does not occur in other Set, Array, Record.

Erg version

Erg 0.6.0-beta.0

Python version

3.10.8

OS

Windows 10