summary refs log tree commit diff stats
path: root/compiler/semstmts.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2013-12-24 01:30:48 +0100
committerAraq <rumpf_a@web.de>2013-12-24 01:30:48 +0100
commit1081c104d06c084e73230d0c7fc73b3824fb4f1d (patch)
treea1861108b9788f961023091d391be7968f187c50 /compiler/semstmts.nim
parentc3b3339e779dfe19ed1891295a763aea47981131 (diff)
parentfeb9af48f1600ce814bc3b62765894ba503ec108 (diff)
downloadNim-1081c104d06c084e73230d0c7fc73b3824fb4f1d.tar.gz
Merge branch 'vm2' of github.com:Araq/Nimrod into vm2
Diffstat (limited to 'compiler/semstmts.nim')
-rw-r--r--compiler/semstmts.nim25
1 files changed, 16 insertions, 9 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index a1805fdec..6f0cc3c8b 100644
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -425,7 +425,9 @@ proc semConst(c: PContext, n: PNode): PNode =
       def = fitRemoveHiddenConv(c, typ, def)
     else:
       typ = def.typ
-    if typ == nil: continue
+    if typ == nil:
+      LocalError(a.sons[2].info, errConstExprExpected)
+      continue
     if not typeAllowed(typ, skConst):
       LocalError(a.info, errXisNoType, typeToString(typ))
       continue
@@ -1159,20 +1161,25 @@ proc setLine(n: PNode, info: TLineInfo) =
 proc semPragmaBlock(c: PContext, n: PNode): PNode =
   let pragmaList = n.sons[0]
   pragma(c, nil, pragmaList, exprPragmas)
-  result = semStmt(c, n.sons[1])
+  result = semExpr(c, n.sons[1])
   for i in 0 .. <pragmaList.len:
     if whichPragma(pragmaList.sons[i]) == wLine:
       setLine(result, pragmaList.sons[i].info)
 
 proc semStaticStmt(c: PContext, n: PNode): PNode =
   let a = semStmt(c, n.sons[0])
-  result = evalStaticExpr(c, c.module, a, c.p.owner)
-  if result.isNil:
-    LocalError(n.info, errCannotInterpretNodeX, renderTree(n))
-    result = emptyNode
-  elif result.kind == nkEmpty:
-    result = newNodeI(nkDiscardStmt, n.info, 1)
-    result.sons[0] = emptyNode
+  n.sons[0] = a
+  evalStaticStmt(c.module, a, c.p.owner)
+  result = newNodeI(nkDiscardStmt, n.info, 1)
+  result.sons[0] = emptyNode
+  when false:
+    result = evalStaticStmt(c.module, a, c.p.owner)
+    if result.isNil:
+      LocalError(n.info, errCannotInterpretNodeX, renderTree(n))
+      result = emptyNode
+    elif result.kind == nkEmpty:
+      result = newNodeI(nkDiscardStmt, n.info, 1)
+      result.sons[0] = emptyNode
 
 proc usesResult(n: PNode): bool =
   # nkStmtList(expr) properly propagates the void context,