diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pure/asyncmacro.nim | 4 | ||||
-rw-r--r-- | lib/pure/ioselects/ioselectors_select.nim | 12 | ||||
-rw-r--r-- | lib/std/assertions.nim | 6 |
3 files changed, 7 insertions, 15 deletions
diff --git a/lib/pure/asyncmacro.nim b/lib/pure/asyncmacro.nim index 63c8e6e5c..d85e3e621 100644 --- a/lib/pure/asyncmacro.nim +++ b/lib/pure/asyncmacro.nim @@ -126,7 +126,9 @@ template await*(f: typed): untyped {.used.} = error "await expects Future[T], got " & $typeof(f) template await*[T](f: Future[T]): auto {.used.} = - template yieldFuture = yield FutureBase() + when not defined(nimHasTemplateRedefinitionPragma): + {.pragma: redefine.} + template yieldFuture {.redefine.} = yield FutureBase() when compiles(yieldFuture): var internalTmpFuture: FutureBase = f diff --git a/lib/pure/ioselects/ioselectors_select.nim b/lib/pure/ioselects/ioselectors_select.nim index 4c38ba604..34c88d85e 100644 --- a/lib/pure/ioselects/ioselectors_select.nim +++ b/lib/pure/ioselects/ioselectors_select.nim @@ -398,18 +398,6 @@ proc contains*[T](s: Selector[T], fd: SocketHandle|int): bool {.inline.} = if s.fds[i].ident == fdi: return true -when hasThreadSupport: - template withSelectLock[T](s: Selector[T], body: untyped) = - acquire(s.lock) - {.locks: [s.lock].}: - try: - body - finally: - release(s.lock) -else: - template withSelectLock[T](s: Selector[T], body: untyped) = - body - proc getData*[T](s: Selector[T], fd: SocketHandle|int): var T = s.withSelectLock(): let fdi = int(fd) diff --git a/lib/std/assertions.nim b/lib/std/assertions.nim index 3d2112b1a..0bc4653f2 100644 --- a/lib/std/assertions.nim +++ b/lib/std/assertions.nim @@ -85,7 +85,9 @@ template onFailedAssert*(msg, code: untyped): untyped {.dirty.} = onFailedAssert(msg): raise (ref MyError)(msg: msg, lineinfo: instantiationInfo(-2)) doAssertRaises(MyError): doAssert false - template failedAssertImpl(msgIMPL: string): untyped {.dirty.} = + when not defined(nimHasTemplateRedefinitionPragma): + {.pragma: redefine.} + template failedAssertImpl(msgIMPL: string): untyped {.dirty, redefine.} = let msg = msgIMPL code @@ -98,7 +100,7 @@ template doAssertRaises*(exception: typedesc, code: untyped) = var wrong = false const begin = "expected raising '" & astToStr(exception) & "', instead" const msgEnd = " by: " & astToStr(code) - template raisedForeign = raiseAssert(begin & " raised foreign exception" & msgEnd) + template raisedForeign {.gensym.} = raiseAssert(begin & " raised foreign exception" & msgEnd) when Exception is exception: try: if true: |