summary refs log blame commit diff stats
path: root/tests/ccgbugs/twrong_discriminant_check.nim
blob: a802f45ef06fe017a3969f05afa805a3701fbc52 (plain) (tree)





























                                                
discard """
  output: "(kind: None)"
"""

when true:
  # bug #2637

  type
    OptionKind = enum
      None,
      Some

    Option*[T] = object
      case kind: OptionKind
      of None:
        discard
      of Some:
        value*: T

  proc none*[T](): Option[T] =
    Option[T](kind: None)

  proc none*(T: typedesc): Option[T] = none[T]()


  proc test(): Option[int] =
    int.none

  echo test()