1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
discard """
targets: "c js"
"""
import std/assertions
block: # bug #4299
proc scopeProc() =
proc normalProc() =
discard
proc genericProc[T]() =
normalProc()
genericProc[string]()
scopeProc()
block: # bug #12492
proc foo() =
var i = 0
proc bar() =
inc i
bar()
doAssert i == 1
foo()
static:
foo()
block: # bug #10849
type
Generic[T] = ref object
getState: proc(): T
proc newGeneric[T](): Generic[T] =
var state: T
proc getState[T](): T =
state
Generic[T](getState: getState)
let g = newGeneric[int]()
let state = g.getState()
doAssert state == 0
|