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,4 +1,5 @@
|
|||
from _erg_result import Error
|
||||
from _erg_control import then__
|
||||
|
||||
class Int(int):
|
||||
def try_new(i): # -> Result[Nat]
|
||||
|
@ -12,6 +13,30 @@ class Int(int):
|
|||
return Int(self - 1)
|
||||
def mutate(self):
|
||||
return IntMut(self)
|
||||
def __add__(self, other):
|
||||
return then__(super().__add__(other), Int)
|
||||
def __radd__(self, other):
|
||||
return then__(super().__radd__(other), Int)
|
||||
def __sub__(self, other):
|
||||
return then__(super().__sub__(other), Int)
|
||||
def __rsub__(self, other):
|
||||
return then__(super().__rsub__(other), Int)
|
||||
def __mul__(self, other):
|
||||
return then__(super().__mul__(other), Int)
|
||||
def __rmul__(self, other):
|
||||
return then__(super().__rmul__(other), Int)
|
||||
def __div__(self, other):
|
||||
return then__(super().__div__(other), Int)
|
||||
def __rdiv__(self, other):
|
||||
return then__(super().__rdiv__(other), Int)
|
||||
def __floordiv__(self, other):
|
||||
return then__(super().__floordiv__(other), Int)
|
||||
def __rfloordiv__(self, other):
|
||||
return then__(super().__rfloordiv__(other), Int)
|
||||
def __pow__(self, other):
|
||||
return then__(super().__pow__(other), Int)
|
||||
def __rpow__(self, other):
|
||||
return then__(super().__rpow__(other), Int)
|
||||
|
||||
class IntMut(): # inherits Int
|
||||
value: Int
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue