summary refs log tree commit diff stats
path: root/tests/ccgbugs/twrong_discriminant_check.nim
blob: a802f45ef06fe017a3969f05afa805a3701fbc52 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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()