Hallo,
the following code
import json
type
A = ref object of RootObj
B = ref object of A
method test(x: A): string =
"got A"
method test(x: B): string =
discard parseJson("{test: 1}") # this line produces warning
"got B"
produces the warning:
test.nim(10, 8) Warning: method has lock level <unknown>, but another method has 0 [LockLevel]
What's going wrong here and how to get rid of this? Thanks in advance!Also you can stick the pragma {.warning[LockLevel]:off.}
inside the effected proc as its first line.
I also noticed that having a proc field in the method receiver seemed to be related to the problem. Anyway, adding the pragma {.locks:0.} to the declaration of the field got rid of one of these warnings - but did not seem to work on others.
Oh well...
BTW it is .locks and not .lock
Hello from the future!
I'm using Nim 1.6 at the moment, moving to 2.0 soon.
I'm targeting a single core system without threading and would like to turn off the locklevel warning project-wide.
--warning[LockLevel]:off
or
switch("warning[LockLevel]","off")
Both give the same result: invalid command line option: '--warning[LockLevel]' Instead I have been adding {. push warning[LockLevel]:off.} to any file where necessary. Is there a better way to do this globally?
Proper solution:
Create a file nim.cfg in your project root dir and put --warning[LockLevel]:off in it (actually manual tells that --warning:LockLevel:off is valid one). You can also name it myprogram.nim.cfg to apply it only to myprogram.nim (more in docs).