erg-lang / erg

A statically typed language compatible with Python
http://erg-lang.org
Apache License 2.0
2.68k stars 55 forks source link

Method redefinition in the REPL #384

Open mtshiba opened 1 year ago

mtshiba commented 1 year ago
>>> C = Class {x = Int}
>>> C
<class '<module>.C'>
>>> C.
...     method self = self::x
Error[#0126]: File <stdin>, line 1,

1 |
  : -
  : `- exists a similar name variable:

NameError: C is not defined

At present, in the REPL, methods must be defined at the same time as classes are defined. However, in a script, the methods part can be separated from the class definition; REPL should follow it.