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

Intentionally defining another function on a predefined function will cause panic #222

Closed GreasySlug closed 1 year ago

GreasySlug commented 1 year ago

Describe the bug?

Defining a function once and then redefining another function for that function will cause a panic, not an error.

Reproducible code

add(x) = x + 1
add(x) = x + 2

Expected result

AssignError: 関数(変数)addに複数回代入することはできません

Actual result

thread '<unnamed>' panicked at 'not yet implemented: L.Output', compiler\erg_compiler\context\instantiate.rs:301:22
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Any { .. }', src\main.rs:64:22

Additional context

In REPL, the error continues after a new line.

>>> a(x) = x

>>> a(x) = x + 1
Error[#0863]: File <stdin>, line 1, in <module>

1 │ a(x) = x + 1
    ----
       ╰─AssignError: 変数aに複数回代入することはできません
>>>
Error[#0887]: File <stdin>, line 1, in <module>

1 │
    -
    ╰─NameError: a: (x: ?6(: Type)) -> ?7(: Type)は宣言されましたが初期化されていません
>>> a
Error[#0887]: File <stdin>, line 1, in <module>

1 │ a
    -
    ╰─NameError: a: (x: ?6(: Type)) -> ?7(: Type)は宣言されましたが初期化されていません
>>> Del a
Error[#0887]: File <stdin>, line 1, in <module>

1 │ Del a
    -
    ╰─NameError: a: (x: ?6(: Type)) -> ?7(: Type)は宣言されましたが初期化されていません

Erg version

Erg 0.5.11-nightly.2

Python version

3.10.6

OS

Windows 10

mtshiba commented 1 year ago

The latest nightly build did not reproduce this problem.