-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
Description
Nim version: 0.18.0 [MacOSX: amd64]
I experimented the behaviour of spawn and parallel for a project, and I got an issue passing an anonymous procedure to spawn.
The following code demonstrates the expected behaviour:
proc my_proc(x: uint32) =
echo x
proc print_parallel_ok(r: uint32) =
for x in 0..r:
spawn my_proc xThe compiler compiles the code, and running it is ok.
Otherwise, the following demonstrates the error:
proc print_parallel_nok(r: uint32) =
for x in 0..r:
spawn (proc (x: uint32) = echo x)Here, instead of using a named procedure, I passed an anonymous procedure to spawn.
The error, passing an anonymous procedure to spawn is: expression 'spawn proc (x: uint32) = echo [x], nimCreateFlowVar' is of type 'FlowVar[proc (x: uint32){.gcsafe, locks: 0.}]' and has to be discarded.
Also, if I add a discard, I get an internal compiler error.