t20141.nim 358 B

12345678910111213141516171819202122232425262728
  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, A](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)