What sort of thing would cause lock level compiler warnings in a program with NO multithreading or semaphores or mutexes etc.?
The warning messages:
Warning: method has lock level <unknown>, but another method has 0
Warning: method has lock level 0, but another method has <unknown>
indicate problems with method foobar in a situation like this:
type ClassA* = ref object of AbaseClass
# no more members
method foobar(self:ClassA) =
...
type ClassB* = ref object of AbaseClass
stuff:int
method foobar(self:ClassB) =
...
However the code does pass unit testing.
I saw a similar post on the forum but the program does NOT use json, so the reply would not seem to apply.
foobar of AbaseClass should use the {.base.} pragma:
type
ClassA* = ref object of AbaseClass
ClassB* = ref object of AbaseClass
stuff:int
method foobar(self:AbaseClass) {.base.} = discard
method foobar(self:ClassA) = discard
method foobar(self:ClassB) = discard
Thanx for responding.
The actual code the example was abstracted from already had the {.base.} pragma.
I had wanted to understand the purpose of the "method has lock level" warnings in general so as to be able to guess at remedies. In particular, did "lock" refer to lock synchronization of multiple threads and if so, why did that error occur in a single threaded application.
I will probably have to pare down the actual code to the irreducible cause of the errors - which may take a while.
I still don't understand the lock level warnings - but I did find a work around.
There were two mutually recursive object type declarations followed by proc declarations for methods on the first one followed by the procs for the second one.
Because some methods for the first type called methods for the second type and vice versa, there were forward declarations of a few of the second type's methods appearing in front of those for the first type.
When I just moved the definitions of the previously forwarded methods up in place of those forwarded declarations, the warnings go away. The unit testing still works.
But I am still puzzled.