summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2018-05-01 11:09:02 +0200
committerAraq <rumpf_a@web.de>2018-05-02 13:34:54 +0200
commit5ac94d26b3691395c40d93109d85fe29d1f14db1 (patch)
tree8e5213d81f2401b07dbbe51dae35cd4791a7003b /compiler
parent599b5d6dcbd8b73d98d1aaf2de94d3360229a699 (diff)
downloadNim-5ac94d26b3691395c40d93109d85fe29d1f14db1.tar.gz
remove the deprecated 'nil' statement
Diffstat (limited to 'compiler')
-rw-r--r--compiler/semstmts.nim29
1 files changed, 11 insertions, 18 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index eafc9ee66..8b466f1da 100644
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -107,30 +107,23 @@ proc fixNilType(n: PNode) =
 proc discardCheck(c: PContext, result: PNode) =
   if c.matchedConcept != nil: return
   if result.typ != nil and result.typ.kind notin {tyStmt, tyVoid}:
-    if result.kind == nkNilLit:
-      result.typ = nil
-      message(result.info, warnNilStatement)
-    elif implicitlyDiscardable(result):
+    if implicitlyDiscardable(result):
       var n = result
       result.typ = nil
       while n.kind in skipForDiscardable:
         n = n.lastSon
         n.typ = nil
     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
-        var s = "expression '" & $n & "' is of type '" &
-            result.typ.typeToString & "' and has to be discarded"
-        if result.info.line != n.info.line or
-           result.info.fileIndex != n.info.fileIndex:
-          s.add "; start of expression here: " & $result.info
-        if result.typ.kind == tyProc:
-          s.add "; for a function call use ()"
-        localError(n.info, s)
+      var n = result
+      while n.kind in skipForDiscardable: n = n.lastSon
+      var s = "expression '" & $n & "' is of type '" &
+          result.typ.typeToString & "' and has to be discarded"
+      if result.info.line != n.info.line or
+          result.info.fileIndex != n.info.fileIndex:
+        s.add "; start of expression here: " & $result.info
+      if result.typ.kind == tyProc:
+        s.add "; for a function call use ()"
+      localError(n.info, s)
 
 proc semIf(c: PContext, n: PNode): PNode =
   result = n