improve error message when using toTask with a call with a return value (#20622)

This commit is contained in:
ringabout
2022-10-23 14:27:34 +08:00
committed by GitHub
parent fa1606c6d6
commit c75cfb363f

View File

@@ -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]):