diff --git a/lib/core/locks.nim b/lib/core/locks.nim index bddd6d8641bcb..da7cd5b6f3888 100644 --- a/lib/core/locks.nim +++ b/lib/core/locks.nim @@ -28,6 +28,10 @@ type {.push stackTrace: off.} + +proc `$`*(lock: Lock): string = + result = "()" + proc initLock*(lock: var Lock) {.inline.} = ## Initializes the given lock. when not defined(js): diff --git a/tests/stdlib/tlocks.nim b/tests/stdlib/tlocks.nim index e567cfde8fdc2..0815c5d013a21 100644 --- a/tests/stdlib/tlocks.nim +++ b/tests/stdlib/tlocks.nim @@ -1,10 +1,10 @@ discard """ - output: '''3''' - cmd: "nim $target --threads:on $options $file" + targets: "c cpp js" + matrix: "--threads:on" """ #bug #6049 import uselocks var m = createMyType[int]() -echo $m.use() +doAssert m.use() == 3 diff --git a/tests/stdlib/uselocks.nim b/tests/stdlib/uselocks.nim index cde9641b22c6c..e9d23f9d9ac27 100644 --- a/tests/stdlib/uselocks.nim +++ b/tests/stdlib/uselocks.nim @@ -9,3 +9,7 @@ proc createMyType*[T]: MyType[T] = proc use* (m: var MyType): int = withLock m.lock: result = 3 + +block: + var l: Lock + doAssert $l == "()"