t23249.nim 455 B

123456789101112131415161718
  1. # issue #23249
  2. type Control* = object
  3. proc onAction*(c: Control, handler: proc(e: int) {.gcsafe.}) = discard
  4. proc onAction*(c: Control, handler: proc() {.gcsafe.}) = discard
  5. template setControlHandlerBlock(c: Control, p: untyped, a: untyped) =
  6. when compiles(c.p(nil)):
  7. c.p() do() {.gcsafe.}: a
  8. else:
  9. c.p = proc() {.gcsafe.} =
  10. a
  11. proc mkLayout() =
  12. var b: Control
  13. setControlHandlerBlock(b, onAction):
  14. echo "hi"