mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-07 05:23:20 +00:00
* Name iterators something human readable
Remove intermediate async procs from stacktraces
Clean async traceback message from reraises message
* Remove unused import/variable
* Fix failing tests
Don't add {.stackTrace: off.} to anonymous procs (They already don't appear in stacktrace)
* Fix failing tests in pragma category
Now check that the nim is a routine type first so we don't run into any assertion defects
* Hide stack trace pragma in docs and update doc tests
User doesn't need to know if something won't appear so this more becomes verbose noise
If this is a bad idea we can always add a `when defined(nimdoc)` switch so we don't add {.stackTrace: off.} to the Future[T] returning proc for docs
31 lines
825 B
Nim
31 lines
825 B
Nim
discard """
|
|
errormsg: "'anotherGCSafeAsyncProc (Async)' is not GC-safe as it calls 'asyncGCUnsafeProc'"
|
|
cmd: "nim c --threads:on $file"
|
|
file: "asyncmacro.nim"
|
|
"""
|
|
|
|
doAssert compileOption("threads"), "this test will not do anything useful without --threads:on"
|
|
|
|
import asyncdispatch
|
|
|
|
var globalDummy: ref int
|
|
proc gcUnsafeProc() =
|
|
if not globalDummy.isNil:
|
|
echo globalDummy[]
|
|
|
|
proc asyncExplicitlyGCSafeProc() {.gcsafe, async.} =
|
|
echo "hi"
|
|
|
|
proc asyncImplicitlyGCSafeProc() {.async.} =
|
|
echo "hi"
|
|
|
|
proc asyncGCUnsafeProc() {.async.} =
|
|
gcUnsafeProc()
|
|
|
|
proc anotherGCSafeAsyncProc() {.async, gcsafe.} =
|
|
# We should be able to call other gcsafe procs
|
|
await asyncExplicitlyGCSafeProc()
|
|
await asyncImplicitlyGCSafeProc()
|
|
# But we can't call gcunsafe procs
|
|
await asyncGCUnsafeProc()
|