t20141.nim 354 B

123456789101112131415161718192021222324252627
  1. discard """
  2. joinable: false
  3. """
  4. # bug #20141
  5. type
  6. A = object
  7. B = object
  8. U = proc()
  9. proc m(h: var B) = discard
  10. template n[T, U](x: U): T =
  11. static: doAssert true
  12. cast[ptr T](addr x)[]
  13. proc k() =
  14. var res: A
  15. m(n[B](res))
  16. proc w(mounter: U) = discard
  17. proc mount(proto: U) = discard
  18. proc v() = mount k
  19. # This is required for failure
  20. w(v)