From 704c95d745587aa023b00bcfcc708396e1b9af1a Mon Sep 17 00:00:00 2001 From: litlighilit Date: Fri, 14 Jun 2024 23:40:02 +0800 Subject: [PATCH] fix: bytearray compile-error about `func` --- src/pylib/pybytearray.nim | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/pylib/pybytearray.nim b/src/pylib/pybytearray.nim index 054ecabae..0ec5c771c 100644 --- a/src/pylib/pybytearray.nim +++ b/src/pylib/pybytearray.nim @@ -23,17 +23,6 @@ template asNim(self: PyByteArray): string = converter toPyBytes*(self): PyBytes = bytes self.data # then all non-inplace method are dispatched to PyBytes -func `*=`*(mself; n: int) = - ## bytearray.__imul__ - ## - ## Python: if n < 1: self.clear() - if n < 1: - mself.data.setLen 0 - return - if n == 1: return - mself.data.add mself.data.repeat n-1 - - # End impl template wrapCmp(op){.dirty.} = @@ -143,6 +132,16 @@ func delitem*(mself; i: int) = func clear*(mself) = mself.asNim.setLen 0 +func `*=`*(mself; n: int) = + ## bytearray.__imul__ + ## + ## Python: if n < 1: self.clear() + if n < 1: + mself.clear() + return + if n == 1: return + mself += bytes mself.data.repeat n-1 + func getCharRef(mself; i: int): var char = mself.asNim[i] func reverse*(mself) =