twrong_discriminant_check.nim 405 B

12345678910111213141516171819202122232425262728293031
  1. discard """
  2. output: "(kind: None)"
  3. """
  4. when true:
  5. # bug #2637
  6. type
  7. OptionKind = enum
  8. None,
  9. Some
  10. Option*[T] = object
  11. case kind: OptionKind
  12. of None:
  13. discard
  14. of Some:
  15. value*: T
  16. proc none*[T](): Option[T] =
  17. Option[T](kind: None)
  18. proc none*(T: typedesc): Option[T] = none[T]()
  19. proc test(): Option[int] =
  20. int.none
  21. echo test()