Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref #14873 #17644

Merged
merged 3 commits into from
Apr 6, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 for # bug #14873
ringabout marked this conversation as resolved.
Show resolved Hide resolved
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 == "()"
Comment on lines +12 to +15
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this in uselocks.nim and not tlocks.nim?

Copy link
Member

@timotheecour timotheecour Apr 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be mlocks.nim:

https://nim-lang.github.io/Nim/contributing.html

All test files are prefixed with t. If you want to create a file for import into another test only, use the prefix m.