summary refs log tree commit diff stats
path: root/compiler/sem.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2014-06-26 17:19:28 +0200
committerAraq <rumpf_a@web.de>2014-06-26 17:19:28 +0200
commit85a1d896c2ccb69d81003673b00ac21b53133b06 (patch)
tree673fdbe85f8291a658282a885d0d80f90d9e230c /compiler/sem.nim
parenteed443d4b390b10e710d80619f5a7bc19fefb8d1 (diff)
parentf793523ade7aa48dcf13ede123a0a434e39e54e0 (diff)
downloadNim-85a1d896c2ccb69d81003673b00ac21b53133b06.tar.gz
Merge branch 'devel' of https://github.com/Araq/Nimrod into new_spawn
Conflicts:
	lib/system.nim
Diffstat (limited to 'compiler/sem.nim')
-rw-r--r--compiler/sem.nim10
1 files changed, 7 insertions, 3 deletions
diff --git a/compiler/sem.nim b/compiler/sem.nim
index 2e3b10a40..e4ef6473f 100644
--- a/compiler/sem.nim
+++ b/compiler/sem.nim
@@ -269,11 +269,15 @@ include hlo, seminst, semcall
 
 proc semAfterMacroCall(c: PContext, n: PNode, s: PSym,
                        flags: TExprFlags): PNode =
+  ## Semantically check the output of a macro.
+  ## This involves processes such as re-checking the macro output for type
+  ## coherence, making sure that variables declared with 'let' aren't
+  ## reassigned, and binding the unbound identifiers that the macro output
+  ## contains.
   inc(evalTemplateCounter)
   if evalTemplateCounter > 100:
     globalError(s.info, errTemplateInstantiationTooNested)
-  let oldFriend = c.friendModule
-  c.friendModule = s.owner.getModule
+  c.friendModules.add(s.owner.getModule)
 
   result = n
   if s.typ.sons[0] == nil:
@@ -297,7 +301,7 @@ proc semAfterMacroCall(c: PContext, n: PNode, s: PSym,
       result = fitNode(c, s.typ.sons[0], result)
       #GlobalError(s.info, errInvalidParamKindX, typeToString(s.typ.sons[0]))
   dec(evalTemplateCounter)
-  c.friendModule = oldFriend
+  discard c.friendModules.pop()
 
 proc semMacroExpr(c: PContext, n, nOrig: PNode, sym: PSym,
                   flags: TExprFlags = {}): PNode =