Skip to content

Commit ceaa03d

Browse files
committed
bypass(NIM-BUG): compiles(<macroCall>) that changes macrocache will take effect
1 parent d32da02 commit ceaa03d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/pylib/pysugar/class.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
import ./stmt/class
3-
export class.new
3+
export class.new, class.init_subclass
44
import ./parserWithCfg
55

66
macro classAux(obj, body: untyped, topLevel: static[bool]): untyped =

src/pylib/pysugar/stmt/class.nim

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ template new*[T; R: ref](_: typedesc[R], cls: typedesc[T],
7979
## py's `object.__new__`
8080
cls
8181

82+
proc init_subclass*[T: ref](cls: typedesc[T]) =
83+
## py's `object.__init_subclass__`
84+
discard
85+
8286
proc recReplaceSuperCall*(n: NimNode, defSupCls: NimNode, start=0, methKind=mkNorm): NimNode =
8387
##[ Recursively maps
8488
@@ -532,11 +536,7 @@ so if wantting the attr inherited from SupCls, just write it as-is (e.g. `self.a
532536
dunderDirId.exportIfTop, dunderDirVal
533537
)
534538
let initSub = newCall("init_subclass").add initSubClassArgs
535-
result.add nnkWhenStmt.newTree(
536-
nnkElifBranch.newTree(newCall("compiles", initSub),
537-
initSub
538-
)
539-
)
539+
result.add initSub
540540

541541
discard parser.classes.pop()
542542
# Echo generated code

0 commit comments

Comments
 (0)