summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2022-10-23 14:27:34 +0800
committerGitHub <noreply@github.com>2022-10-23 08:27:34 +0200
commitc75cfb363fb8a827774892c76f3417efcf58cba0 (patch)
treed28d82618a80b79ba403ec21272f7118fafcf42b
parentfa1606c6d6799823de51f7a273ae5da2f3fa6e3a (diff)
downloadNim-c75cfb363fb8a827774892c76f3417efcf58cba0.tar.gz
improve error message when using `toTask` with a call with a return value (#20622)
-rw-r--r--lib/std/tasks.nim3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/std/tasks.nim b/lib/std/tasks.nim
index ac35e26bf..055ddf144 100644
--- a/lib/std/tasks.nim
+++ b/lib/std/tasks.nim
@@ -110,7 +110,8 @@ macro toTask*(e: typed{nkCall | nkInfix | nkPrefix | nkPostfix | nkCommand | nkC
     let b = toTask hello(13)
     assert b is Task
 
-  doAssert getTypeInst(e).typeKind == ntyVoid
+  if getTypeInst(e).typeKind != ntyVoid:
+    error("'toTask' cannot accept a call with a return value", e)
 
   when compileOption("threads"):
     if not isGcSafe(e[0]):