From c75cfb363fb8a827774892c76f3417efcf58cba0 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Sun, 23 Oct 2022 14:27:34 +0800 Subject: improve error message when using `toTask` with a call with a return value (#20622) --- lib/std/tasks.nim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib') 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]): -- cgit 1.4.1-2-gfad0