pragmagic / vscode-nim

An extension for VS Code which provides support for the Nim language.
Other
235 stars 38 forks source link

add support to "nim check" for Threads and Channels #110

Closed brianonn closed 5 years ago

brianonn commented 5 years ago

test with the following code snippet:

import os, threadpool

var chan: Channel[string]
open (chan)

proc sayHello () =
  chan.send("Hello" )

spawn sayHello()
echo chan.recv()

You get the following errors without this small patch:

image

when the patch is applied, the checker understands the threadpool classes:

image

The patch is simple and adds --threads:on to the check command. Since threads:on was introduced over 4 years ago and it's not harmful to leave it on the command line even when not using threads, I would consider this a safe fix.

However, an improvement would be to use a workspace configuration variable (maybe something like nim.checkFlags` ) for supplying additional flags to the check command.

endragor commented 5 years ago

You should simply put nim.cfg in your project folder, specifying the additional flags there. nim check will use them as well as other nim commands. We would like to provide actual compilation results with nim check, and if someone compiles without --threads:on using the threads module is an error.

brianonn commented 5 years ago

@endragor ah, ok. good point. I didn't realize that nim check would use the compiler flags from the cfg file too. Using the cfg file is a better, more general solution and I will close this PR then.

Cheers !