summary refs log blame commit diff stats
path: root/tests/objvariant/trt_discrim_err1.nim
blob: de29420a2f9ec095d299b1e101ea02f2219821c7 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
















                                                                                                             
discard """
  errormsg: "branch initialization with a runtime discriminator is not supported inside of an `elif` branch."
  line: 16
"""
type
  Color = enum Red, Green, Blue
  ColorObj = object
    case colorKind: Color
    of Red: red: string
    of Green: green: string
    of Blue: blue: string

let colorKind = Blue
case colorKind
of Red: echo ColorObj(colorKind: colorKind, red: "red")
elif colorKind == Green: echo ColorObj(colorKind: colorKind, green: "green")
else: echo ColorObj(colorKind: colorKind, blue: "blue")