* fixes #18059
This commit is contained in:
Andreas Rumpf 2021-06-02 13:13:23 +02:00 • committed by GitHub
commit f10eef29b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 80 additions and 3 deletions

35
tests/metatype/tcps.nim Normal file
View file

@ -0,0 +1,35 @@
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")