Skip to content

Commit 382914e

Browse files
committed
bypass(NIM-BUG): compiles(<macroCall>) that changes macrocache will take effect
1 parent 741dffd commit 382914e

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](cls: typedesc[ref 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
@@ -523,11 +527,7 @@ so if wantting the attr inherited from SupCls, just write it as-is (e.g. `self.a
523527
dunderDirId.exportIfTop, dunderDirVal
524528
)
525529
let initSub = newCall("init_subclass").add initSubClassArgs
526-
result.add nnkWhenStmt.newTree(
527-
nnkElifBranch.newTree(newCall("compiles", initSub),
528-
initSub
529-
)
530-
)
530+
result.add initSub
531531

532532
discard parser.classes.pop()
533533
# Echo generated code

0 commit comments

Comments
 (0)