fix #7535(Poor error message for spawn when a procedure (without calling it)) (#17774)
This commit is contained in:
parent
8f79bc5f3d
commit
4471141a1d
2 changed files with 16 additions and 2 deletions
|
|
@ -2282,12 +2282,15 @@ proc semMagic(c: PContext, n: PNode, s: PSym, flags: TExprFlags): PNode =
|
||||||
of mSpawn:
|
of mSpawn:
|
||||||
markUsed(c, n.info, s)
|
markUsed(c, n.info, s)
|
||||||
when defined(leanCompiler):
|
when defined(leanCompiler):
|
||||||
localError(c.config, n.info, "compiler was built without 'spawn' support")
|
result = localErrorNode(c, n, "compiler was built without 'spawn' support")
|
||||||
result = n
|
|
||||||
else:
|
else:
|
||||||
result = setMs(n, s)
|
result = setMs(n, s)
|
||||||
for i in 1..<n.len:
|
for i in 1..<n.len:
|
||||||
result[i] = semExpr(c, n[i])
|
result[i] = semExpr(c, n[i])
|
||||||
|
|
||||||
|
if n.len > 1 and n[1].kind notin nkCallKinds:
|
||||||
|
return localErrorNode(c, n, n[1].info, "'spawn' takes a call expression; got " & $n[1])
|
||||||
|
|
||||||
let typ = result[^1].typ
|
let typ = result[^1].typ
|
||||||
if not typ.isEmptyType:
|
if not typ.isEmptyType:
|
||||||
if spawnResult(typ, c.inParallelStmt > 0) == srFlowVar:
|
if spawnResult(typ, c.inParallelStmt > 0) == srFlowVar:
|
||||||
|
|
|
||||||
11
tests/parallel/t7535.nim
Normal file
11
tests/parallel/t7535.nim
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
discard """
|
||||||
|
matrix: "--threads:on"
|
||||||
|
errormsg: "'spawn' takes a call expression; got proc (x: uint32) = echo [x]"
|
||||||
|
"""
|
||||||
|
|
||||||
|
import threadpool
|
||||||
|
|
||||||
|
# bug #7535
|
||||||
|
proc print_parallel_nok(r: uint32) =
|
||||||
|
for x in 0..r:
|
||||||
|
spawn (proc (x: uint32) = echo x)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue