Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

report expression has no type other than has to be used (or discarded… #20392

Merged
merged 1 commit into from
Sep 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions compiler/semstmts.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
6 changes: 6 additions & 0 deletions tests/errmsgs/t8064.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
discard """
errormsg: "expression has no type: values"
"""
import tables

values