summary refs log tree commit diff stats
path: root/compiler/semstmts.nim
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/semstmts.nim')
-rw-r--r--compiler/semstmts.nim21
1 files changed, 11 insertions, 10 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index 50543466a..f21f5122c 100644
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -784,7 +784,8 @@ proc isTrivalStmtExpr(n: PNode): bool =
       return false
   result = true
 
-proc handleStmtMacro(c: PContext; n, selector: PNode; magicType: string): PNode =
+proc handleStmtMacro(c: PContext; n, selector: PNode; magicType: string;
+                     flags: TExprFlags): PNode =
   if selector.kind in nkCallKinds:
     # we transform
     # n := for a, b, c in m(x, y, z): Y
@@ -813,14 +814,14 @@ proc handleStmtMacro(c: PContext; n, selector: PNode; magicType: string): PNode
     callExpr.add newSymNode(match)
     callExpr.add n
     case match.kind
-    of skMacro: result = semMacroExpr(c, callExpr, callExpr, match, {})
-    of skTemplate: result = semTemplateExpr(c, callExpr, match, {})
+    of skMacro: result = semMacroExpr(c, callExpr, callExpr, match, flags)
+    of skTemplate: result = semTemplateExpr(c, callExpr, match, flags)
     else: result = nil
 
-proc handleForLoopMacro(c: PContext; n: PNode): PNode =
-  result = handleStmtMacro(c, n, n[^2], "ForLoopStmt")
+proc handleForLoopMacro(c: PContext; n: PNode; flags: TExprFlags): PNode =
+  result = handleStmtMacro(c, n, n[^2], "ForLoopStmt", flags)
 
-proc handleCaseStmtMacro(c: PContext; n: PNode): PNode =
+proc handleCaseStmtMacro(c: PContext; n: PNode; flags: TExprFlags): PNode =
   # n[0] has been sem'checked and has a type. We use this to resolve
   # 'match(n[0])' but then we pass 'n' to the 'match' macro. This seems to
   # be the best solution.
@@ -840,8 +841,8 @@ proc handleCaseStmtMacro(c: PContext; n: PNode): PNode =
     r.call[1] = n
     let toExpand = semResolvedCall(c, r, r.call, {})
     case match.kind
-    of skMacro: result = semMacroExpr(c, toExpand, toExpand, match, {})
-    of skTemplate: result = semTemplateExpr(c, toExpand, match, {})
+    of skMacro: result = semMacroExpr(c, toExpand, toExpand, match, flags)
+    of skTemplate: result = semTemplateExpr(c, toExpand, match, flags)
     else: result = nil
   # this would be the perfectly consistent solution with 'for loop macros',
   # but it kinda sucks for pattern matching as the matcher is not attached to
@@ -852,7 +853,7 @@ proc handleCaseStmtMacro(c: PContext; n: PNode): PNode =
 proc semFor(c: PContext, n: PNode; flags: TExprFlags): PNode =
   checkMinSonsLen(n, 3, c.config)
   if forLoopMacros in c.features:
-    result = handleForLoopMacro(c, n)
+    result = handleForLoopMacro(c, n, flags)
     if result != nil: return result
   openScope(c)
   result = n
@@ -914,7 +915,7 @@ proc semCase(c: PContext, n: PNode; flags: TExprFlags): PNode =
     popCaseContext(c)
     closeScope(c)
     if caseStmtMacros in c.features:
-      result = handleCaseStmtMacro(c, n)
+      result = handleCaseStmtMacro(c, n, flags)
       if result != nil:
         return result
     localError(c.config, n[0].info, errSelectorMustBeOfCertainTypes)
15e7d768a57436d171edc3831'>^
60b351b ^

80e891a ^

60b351b ^
80e891a ^
60b351b ^

80e891a ^
77a0f68 ^

80e891a ^
77a0f68 ^

60b351b ^



db1b2cd ^


60b351b ^
80e891a ^
db1b2cd ^

60b351b ^
77a0f68 ^
80e891a ^


cab3771 ^
80e891a ^
77a0f68 ^

80e891a ^



60b351b ^
77a0f68 ^
cab3771 ^
60b351b ^

80e891a ^
60b351b ^

db1b2cd ^


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84