mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-28 04:09:05 +00:00
Fix builtin types methods
This commit is contained in:
parent
c56ef64576
commit
8cdc735486
12 changed files with 180 additions and 7 deletions
|
@ -1,6 +1,6 @@
|
|||
from _erg_result import Error
|
||||
from _erg_int import Int
|
||||
from _erg_int import IntMut
|
||||
from _erg_int import Int, IntMut
|
||||
from _erg_control import then__
|
||||
|
||||
class Nat(Int):
|
||||
def try_new(i): # -> Result[Nat]
|
||||
|
@ -20,6 +20,10 @@ class Nat(Int):
|
|||
return 0
|
||||
def mutate(self):
|
||||
return NatMut(self)
|
||||
def __add__(self, other):
|
||||
return then__(super().__add__(other), Nat)
|
||||
def __mul__(self, other):
|
||||
return then__(super().__mul__(other), Nat)
|
||||
|
||||
class NatMut(IntMut): # and Nat
|
||||
value: Nat
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue