diff options
author | Jasper Jenkins <jasper.vs.jenkins@gmail.com> | 2019-04-30 23:53:20 -0700 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-05-01 08:53:20 +0200 |
commit | 60e3d7930d9d4e39d8233bac282b2219f69483c2 (patch) | |
tree | 5f486dc6e25fc4d1a8fa4da84aaaed3f92d6b6f6 /compiler | |
parent | 3d0190f470d345eafca5260bb0e350d062edffcd (diff) | |
download | Nim-60e3d7930d9d4e39d8233bac282b2219f69483c2.tar.gz |
discard type is an error, fixes #7470 (#11146)
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/semstmts.nim | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 230a9c0d4..b8f35408f 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -43,7 +43,7 @@ proc semDiscard(c: PContext, n: PNode): PNode = 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: + if isEmptyType(sonType) or sonType.kind in {tyNone, tyTypeDesc} or sonKind == nkTypeOfExpr: localError(c.config, n.info, errInvalidDiscard) if sonType.kind == tyProc and sonKind notin nkCallKinds: # tyProc is disallowed to prevent ``discard foo`` to be valid, when ``discard foo()`` is meant. |