summary refs log tree commit diff stats
path: root/compiler/semstmts.nim
diff options
context:
space:
mode:
authorArne Döring <arne.doering@gmx.net>2018-11-20 13:12:47 +0100
committerGitHub <noreply@github.com>2018-11-20 13:12:47 +0100
commit39ad3a0da69908ab937ea2156f06f4d3bbd0b2b7 (patch)
tree6d7d40a6a29dba52d65330b419ae07cbdab052a3 /compiler/semstmts.nim
parentd146516008973232b690c977b238af487a809541 (diff)
downloadNim-39ad3a0da69908ab937ea2156f06f4d3bbd0b2b7.tar.gz
fix #9726 (#9765)
Diffstat (limited to 'compiler/semstmts.nim')
-rw-r--r--compiler/semstmts.nim5
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index adc94f24c..1f2b9f0b3 100644
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -42,10 +42,11 @@ proc semDiscard(c: PContext, n: PNode): PNode =
   if n.sons[0].kind != nkEmpty:
     n.sons[0] = semExprWithType(c, n.sons[0])
     let sonType = n.sons[0].typ
+    let sonKind = n.sons[0].kind
     if isEmptyType(sonType) or sonType.kind == tyNone or n.sons[0].kind == nkTypeOfExpr:
       localError(c.config, n.info, errInvalidDiscard)
-    if sonType.kind == tyProc:
-      # tyProc is disallowed to prevent ``discard foo`` to pass, when ``discard foo()`` is meant.
+    if sonType.kind == tyProc and sonKind notin nkCallKinds:
+      # tyProc is disallowed to prevent ``discard foo`` to be valid, when ``discard foo()`` is meant.
       localError(c.config, n.info, "illegal discard proc, did you mean: " & $n[0] & "()")
 
 proc semBreakOrContinue(c: PContext, n: PNode): PNode =