mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-30 04:44:44 +00:00
Fix codegen bug
This commit is contained in:
parent
c2e7f78b73
commit
e26a89c0b3
7 changed files with 73 additions and 28 deletions
|
@ -1 +1 @@
|
|||
.expanduser!: (path: PathLike,) => NoneType
|
||||
.expanduser!: (path: PathLike,) => Str
|
||||
|
|
6
compiler/erg_compiler/lib/pystd/shutil.d.er
Normal file
6
compiler/erg_compiler/lib/pystd/shutil.d.er
Normal file
|
@ -0,0 +1,6 @@
|
|||
.copyfile!: (src: PathLike, dst: PathLike,) => NoneType
|
||||
.copy!: (src: PathLike, dst: PathLike,) => NoneType
|
||||
.copytree!: (src: PathLike, dst: PathLike,) => NoneType
|
||||
.rmtree!: (path: PathLike,) => NoneType
|
||||
.move!: (src: PathLike, dst: PathLike) => NoneType
|
||||
.which!: (cmd: Str,) => Str or NoneType
|
|
@ -1,7 +1,8 @@
|
|||
.ZipFile!: ClassType
|
||||
.ZipFile! <: FileLike!
|
||||
|
||||
.ZipFile!.open!: (path: PathLike or FileLike!, mode := Str) => .ZipFile!
|
||||
.open! = 'ZipFile': (path: PathLike or FileLike!, mode := Str) => .ZipFile!
|
||||
.ZipFile!.open!: (name: PathLike, mode := Str) => .ZipFile!
|
||||
.ZipFile!.add!: (self: RefMut(.ZipFile!), name: PathLike, arcname: PathLike or NoneType := NoneType, recursive := Bool) => NoneType
|
||||
.ZipFile!.close!: (self: .ZipFile!,) => NoneType
|
||||
.ZipFile!.extractall!: (self: RefMut(.ZipFile!), path := PathLike, members: [Str; _] or NoneType := NoneType, numeric_owner := Bool) => NoneType
|
||||
|
|
|
@ -67,7 +67,6 @@ class Bool(Nat):
|
|||
|
||||
class Str(str):
|
||||
def __instancecheck__(cls, obj):
|
||||
print(cls, obj)
|
||||
return obj == Str or obj == str
|
||||
|
||||
def try_new(s: str): # -> Result[Nat]
|
||||
|
@ -133,10 +132,10 @@ class RangeIterator:
|
|||
def __init__(self, rng):
|
||||
self.rng = rng
|
||||
self.needle = self.rng.start
|
||||
if type(self.rng.start) == int:
|
||||
if issubclass(Nat, type(self.rng.start)):
|
||||
if not(self.needle in self.rng):
|
||||
self.needle += 1
|
||||
elif type(self.rng.start) == str:
|
||||
elif issubclass(Str, type(self.rng.start)):
|
||||
if not(self.needle in self.rng):
|
||||
self.needle = chr(ord(self.needle) + 1)
|
||||
else:
|
||||
|
@ -147,12 +146,12 @@ class RangeIterator:
|
|||
return self
|
||||
|
||||
def __next__(self):
|
||||
if type(self.rng.start) == int:
|
||||
if issubclass(Nat, type(self.rng.start)):
|
||||
if self.needle in self.rng:
|
||||
result = self.needle
|
||||
self.needle += 1
|
||||
return result
|
||||
elif type(self.rng.start) == str:
|
||||
elif issubclass(Str, type(self.rng.start)):
|
||||
if self.needle in self.rng:
|
||||
result = self.needle
|
||||
self.needle = chr(ord(self.needle) + 1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue