Fix builtin types methods

This commit is contained in:
Shunsuke Shibayama 2023-02-03 00:23:42 +09:00
parent c56ef64576
commit 8cdc735486
12 changed files with 180 additions and 7 deletions

View file

@ -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