Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* ref nim-lang#14873

* comment

* Update lib/core/locks.nim
  • Loading branch information
ringabout authored and PMunch committed Mar 28, 2022
1 parent d356ab9 commit 9d82dcf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions lib/core/locks.nim
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ type

{.push stackTrace: off.}


proc `$`*(lock: Lock): string =
# workaround bug #14873
result = "()"

proc initLock*(lock: var Lock) {.inline.} =
## Initializes the given lock.
when not defined(js):
Expand Down
6 changes: 3 additions & 3 deletions tests/stdlib/tlocks.nim
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions tests/stdlib/uselocks.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "()"

0 comments on commit 9d82dcf

Please sign in to comment.