Files
Nim/tests/generics/t22305.nim
Jacek Sieka 7fa006c4e5 fix invalid join (#25896)
can't join a thread that wasn't started (causes random crashes)
2026-06-11 20:24:48 +02:00

49 lines
978 B
Nim

discard """
joinable: false
"""
import asyncdispatch, options
proc recv*[T](tc: ptr Channel[T]): Future[T] {.async.} =
discard
type SharedBuf = object
type WorkProc[A, B] = proc(a: A): Option[B] {.nimcall.}
proc worker[TArg](p: TArg) {.thread, nimcall.} =
discard
proc readFilesAd() {.async.} =
var readChan: Channel[Option[int]]
type TArg[A, B] =
tuple[r: ptr Channel[Option[A]], w: ptr Channel[Option[B]], p: WorkProc[A, B]]
var readThread: Thread[TArg[int, SharedBuf]]
let test = await (addr readChan).recv()
waitFor readFilesAd()
type
SharedPtr[T] = object
p: ptr T
proc `=destroy`[T](self: var SharedPtr[T]) =
discard
type
SomethingObj[T] = object
Something[T] = SharedPtr[SomethingObj[T]]
proc useSomething() =
# discard Something[int]() # When you uncomment this line, it will compile successfully.
discard Something[float]()
proc fn() =
let thing = Something[int]()
proc closure() =
discard thing
closure()
fn()