summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorBung <crc32@qq.com>2022-09-20 20:50:48 +0800
committerGitHub <noreply@github.com>2022-09-20 14:50:48 +0200
commit08c02f0236eec5957d54cc7f263461e06cb09a2a (patch)
treec24fafa4a75169452a890c8d3d353adb8ae2dac5 /compiler
parenta302b26e0eaa7a2074d3caac72f7c8a7e79993c5 (diff)
downloadNim-08c02f0236eec5957d54cc7f263461e06cb09a2a.tar.gz
report expression has no type other than has to be used (or discarded… (#20392)
report expression has no type other than has to be used (or discarded) when typ is tyNone in discardCheck
Diffstat (limited to 'compiler')
-rw-r--r--compiler/semstmts.nim3
1 files changed, 3 insertions, 0 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index 64d56f812..1e8930fc9 100644
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -139,6 +139,9 @@ proc discardCheck(c: PContext, result: PNode, flags: TExprFlags) =
       var n = newNodeI(nkDiscardStmt, result.info, 1)
       n[0] = result
     elif result.typ.kind != tyError and c.config.cmd != cmdInteractive:
+      if result.typ.kind == tyNone:
+        localError(c.config, result.info, "expression has no type: " &
+               renderTree(result, {renderNoComments}))
       var n = result
       while n.kind in skipForDiscardable:
         if n.kind == nkTryStmt: n = n[0]