trt_discrim_err3.nim 410 B

123456789101112131415161718
  1. discard """
  2. errormsg: "runtime discriminator must be immutable if branch fields are initialized, a 'let' binding is required."
  3. line: 16
  4. """
  5. type
  6. Kind = enum k1, k2, k3, k4, k5
  7. KindObj = object
  8. case kind: Kind
  9. of k1, k2..k3: i32: int32
  10. of k4: f32: float32
  11. else: str: string
  12. var kind = k3
  13. case kind
  14. of k2: discard KindObj(kind: kind, i32: 1)
  15. else: discard KindObj(kind: kind, str: "3")