summary refs log tree commit diff stats
path: root/compiler/semstmts.nim
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/semstmts.nim')
-rwxr-xr-xcompiler/semstmts.nim13
1 files changed, 9 insertions, 4 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index 4b79291e6..b62f77888 100755
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -62,8 +62,9 @@ proc semIf(c: PContext, n: PNode): PNode =
 proc semDiscard(c: PContext, n: PNode): PNode = 
   result = n
   checkSonsLen(n, 1)
-  n.sons[0] = semExprWithType(c, n.sons[0])
-  if n.sons[0].typ == nil: localError(n.info, errInvalidDiscard)
+  if n.sons[0].kind != nkEmpty:
+    n.sons[0] = semExprWithType(c, n.sons[0])
+    if n.sons[0].typ == nil: localError(n.info, errInvalidDiscard)
   
 proc semBreakOrContinue(c: PContext, n: PNode): PNode =
   result = n
@@ -935,7 +936,8 @@ proc semStaticStmt(c: PContext, n: PNode): PNode =
   if result.isNil:
     LocalError(n.info, errCannotInterpretNodeX, renderTree(n))
   elif result.kind == nkEmpty:
-    result = newNodeI(nkNilLit, n.info)
+    result = newNodeI(nkDiscardStmt, n.info, 1)
+    result.sons[0] = emptyNode
 
 # special marker values that indicates that we are
 # 1) AnalyzingDestructor: currenlty analyzing the type for destructor 
@@ -1132,7 +1134,10 @@ proc SemStmt(c: PContext, n: PNode): PNode =
   of nkAsgn: result = semAsgn(c, n)
   of nkCall, nkInfix, nkPrefix, nkPostfix, nkCommand, nkMacroStmt, nkCallStrLit: 
     result = semCommand(c, n)
-  of nkEmpty, nkCommentStmt, nkNilLit: nil
+  of nkEmpty, nkCommentStmt: nil
+  of nkNilLit:
+    # XXX too much work and fixing would break bootstrapping:
+    #Message(n.info, warnNilStatement)
   of nkBlockStmt: result = semBlock(c, n)
   of nkStmtList: 
     var length = sonsLen(n)