summary refs log tree commit diff stats
path: root/compiler/semstmts.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2014-01-19 16:54:59 +0100
committerAraq <rumpf_a@web.de>2014-01-19 16:54:59 +0100
commit73c6efdf66dd62370cb04f7ce75640743905edc5 (patch)
tree5ffe8181b782134db74b439fedca073536f3a9f4 /compiler/semstmts.nim
parentcde9e5d64421e34d7d844c048213f01c40af5dd7 (diff)
downloadNim-73c6efdf66dd62370cb04f7ce75640743905edc5.tar.gz
'nil' as a statement is deprecated, use an empty 'discard' instead
Diffstat (limited to 'compiler/semstmts.nim')
-rw-r--r--compiler/semstmts.nim10
1 files changed, 6 insertions, 4 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index f0007d01e..1aa6a793c 100644
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -136,6 +136,7 @@ proc discardCheck(c: PContext, result: PNode) =
   if result.typ != nil and result.typ.kind notin {tyStmt, tyEmpty}:
     if result.kind == nkNilLit:
       result.typ = nil
+      message(result.info, warnNilStatement)
     elif implicitlyDiscardable(result):
       var n = result
       result.typ = nil
@@ -145,10 +146,11 @@ proc discardCheck(c: PContext, result: PNode) =
     elif c.inTypeClass > 0 and result.typ.kind == tyBool:
       let verdict = semConstExpr(c, result)
       if verdict.intVal == 0:
-        localError(result.info, "type class predicate failed.")
+        localError(result.info, "type class predicate failed")
     elif result.typ.kind != tyError and gCmd != cmdInteractive:
       if result.typ.kind == tyNil:
         fixNilType(result)
+        message(result.info, warnNilStatement)
       else:
         var n = result
         while n.kind in skipForDiscardable: n = n.lastSon
@@ -996,7 +998,7 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind,
   if proto == nil: 
     s.typ.callConv = lastOptionEntry(c).defaultCC
     # add it here, so that recursive procs are possible:
-    if sfGenSym in s.flags: nil
+    if sfGenSym in s.flags: discard
     elif kind in OverloadableSyms:
       if not typeIsDetermined:
         addInterfaceOverloadableSymAt(c, s.scope, s)
@@ -1252,9 +1254,9 @@ proc semStmtList(c: PContext, n: PNode): PNode =
       of LastBlockStmts: 
         for j in countup(i + 1, length - 1): 
           case n.sons[j].kind
-          of nkPragma, nkCommentStmt, nkNilLit, nkEmpty: nil
+          of nkPragma, nkCommentStmt, nkNilLit, nkEmpty: discard
           else: localError(n.sons[j].info, errStmtInvalidAfterReturn)
-      else: nil
+      else: discard
   if result.len == 1:
     result = result.sons[0]
   when false: