Skip to content

Commit 0fb9426

Browse files
committed
fix(sugar): @a.b not compile
1 parent f6c2824 commit 0fb9426

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/pylib/pysugar/stmt/class.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ so if wantting the attr inherited from SupCls, just write it as-is (e.g. `self.a
356356

357357
of nnkStrLit, nnkRStrLit, nnkTripleStrLit:
358358
result.add newCommentStmtNode $def
359-
of nnkPrefix:
359+
of nnkPrefix, nnkDotExpr:
360360
if not parser.tryHandleDecorator def:
361361
result.add def
362362
else:

src/pylib/pysugar/stmt/decorator.nim

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ proc pushDecorator*(mparser; item: NimNode) =
1010
## parse `@<item>`
1111
var dec: Decorator
1212
case item.kind
13-
of nnkIdent:
13+
of nnkIdent, nnkDotExpr:
1414
dec = Decorator(name: item, called: false)
1515
of nnkCall:
1616
dec = Decorator(name: item[0], called: true, args: item[1..^1])
@@ -29,6 +29,17 @@ proc tryHandleDecorator*(mparser; statement: NimNode): bool =
2929
let item = statement[1]
3030
mparser.pushDecorator item
3131
return true
32+
elif statement.kind == nnkDotExpr:
33+
#[ @module.decorator ->
34+
DotExpr
35+
Prefix
36+
Ident "@"
37+
Ident "module"
38+
Ident "decorator"]#
39+
let pre = statement[0]
40+
if pre.kind == nnkPrefix and pre[0].eqIdent "@":
41+
mparser.pushDecorator newDotExpr(pre[1], statement[1])
42+
return true
3243

3344
proc unpackCall(callee: NimNode, arg: seq[NimNode]): NimNode =
3445
result = newCall callee

0 commit comments

Comments
 (0)