summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorZahary Karadjov <zahary@gmail.com>2013-08-07 00:01:58 +0300
committerZahary Karadjov <zahary@gmail.com>2013-08-07 00:01:58 +0300
commit5c32156a715b39061ee2bc353e886991fef28ab2 (patch)
tree6a9d4f04de6bde3b7f1bae9b50506dec0a077658
parent015b814e6ae0b99a2564d2d3b38469a762363f2e (diff)
downloadNim-5c32156a715b39061ee2bc353e886991fef28ab2.tar.gz
fixes #534
-rw-r--r--compiler/semexprs.nim4
-rw-r--r--compiler/sempass2.nim7
2 files changed, 8 insertions, 3 deletions
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index a524e71da..4591c3942 100644
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -1361,7 +1361,9 @@ proc semQuoteAst(c: PContext, n: PNode): PNode =
     ids = newSeq[PNode]()
       # this will store the generated param names
 
-  internalAssert doBlk.kind == nkDo
+  if doBlk.kind != nkDo:
+    LocalError(n.info, errXExpected, "block")
+
   processQuotations(doBlk.sons[bodyPos], op, quotes, ids)
   
   doBlk.sons[namePos] = newAnonSym(skTemplate, n.info).newSymNode
diff --git a/compiler/sempass2.nim b/compiler/sempass2.nim
index f2e4fb02e..7dec557be 100644
--- a/compiler/sempass2.nim
+++ b/compiler/sempass2.nim
@@ -448,8 +448,11 @@ proc track(tracked: PEffects, n: PNode) =
     # p's effects are ours too:
     let a = n.sons[0]
     let op = a.typ
-    if op != nil and op.kind == tyProc:
-      InternalAssert op.n.sons[0].kind == nkEffectList
+    # XXX: in rare situations, templates and macros will reach here after
+    # calling getAst(templateOrMacro()). Currently, templates and macros
+    # are indistinguishable from normal procs (both have tyProc type) and
+    # we can detect them only by cheking for attached nkEffectList.
+    if op != nil and op.kind == tyProc and op.n.sons[0].kind == nkEffectList:
       var effectList = op.n.sons[0]
       if a.kind == nkSym and a.sym.kind == skMethod:
         propagateEffects(tracked, n, a.sym)