tnotnil_in_generic.nim 334 B

1234567891011121314151617181920212223242526272829
  1. discard """
  2. errormsg: "cannot prove 'x' is not nil"
  3. """
  4. # bug #2216
  5. {.experimental: "notnil".}
  6. type
  7. A[T] = ref object
  8. x: int
  9. ud: T
  10. proc good[T](p: A[T]) =
  11. discard
  12. proc bad[T](p: A[T] not nil) =
  13. discard
  14. proc go() =
  15. let s = A[int](x: 1)
  16. good(s)
  17. bad(s)
  18. var x: A[int]
  19. bad(x)
  20. go()