tnotnil1.nim 298 B

12345678910111213141516171819202122232425262728
  1. discard """
  2. errormsg: "'y' is provably nil"
  3. line:25
  4. """
  5. import strutils
  6. {.experimental: "notnil".}
  7. type
  8. TObj = object
  9. x, y: int
  10. proc q(x: pointer not nil) =
  11. discard
  12. proc p() =
  13. var x: pointer
  14. if not x.isNil:
  15. q(x)
  16. let y = x
  17. if not y.isNil:
  18. q(y)
  19. else:
  20. q(y)
  21. p()