tcaseexpr1.nim 593 B

12345678910111213141516171819202122232425262728293031323334
  1. discard """
  2. errormsg: "type mismatch: got <string> but expected 'int'"
  3. line: 33
  4. file: "tcaseexpr1.nim"
  5. errormsg: "not all cases are covered; missing: {C}"
  6. line: 27
  7. file: "tcaseexpr1.nim"
  8. """
  9. # NOTE: This spec is wrong. Spec doesn't support multiple error
  10. # messages. The first one is simply overridden by the second one.
  11. # This just has never been noticed.
  12. type
  13. E = enum A, B, C
  14. proc foo(x: int): auto =
  15. return case x
  16. of 1..9: "digit"
  17. else: "number"
  18. var r = foo(10)
  19. var x = C
  20. var t1 = case x:
  21. of A: "a"
  22. of B: "b"
  23. var t2 = case x:
  24. of A: 10
  25. of B, C: "23"