From 60e3d7930d9d4e39d8233bac282b2219f69483c2 Mon Sep 17 00:00:00 2001 From: Jasper Jenkins Date: Tue, 30 Apr 2019 23:53:20 -0700 Subject: [PATCH] discard type is an error, fixes #7470 (#11146) --- compiler/semstmts.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 230a9c0d43..b8f35408f6 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.