Nim/tests/metatype/tcps.nim
Andreas Rumpf f10eef29b5
fixes #18059 (#18140)
* fixes #18059
2021-06-02 13:13:23 +02:00

35 lines
529 B
Nim

discard """
output: '''10
string'''
"""
# bug #18059
type
C = ref object of RootObj
fn: ContProc
ex: ref Exception
ContProc = proc (c: C): C {.nimcall.}
proc noop(c: C): C = c
type
Env[T] = ref object of C
x: T
proc foo_cont[U](c: C): C =
proc afterCall[V](c: C): C =
echo Env[V](c).x
c.fn = afterCall[U]
return noop(c)
proc foo[T](x: T): C =
return Env[T](fn: foo_cont[T], x: x)
proc tramp(c: sink C) =
while c != nil and c.fn != nil:
c = c.fn(c)
tramp foo(10)
tramp foo("string")