tenums.nim 933 B

12345678910111213141516171819202122232425262728293031323334
  1. discard """
  2. cmd: "nim check --hints:off $file"
  3. errormsg: "type mismatch: got <BC>"
  4. nimout: '''
  5. tenums.nim(32, 20) Error: type mismatch: got <Letters>
  6. but expected one of:
  7. proc takesChristmasColor(color: ChristmasColors)
  8. first type mismatch at position: 1
  9. required type for color: ChristmasColors
  10. but expression 'A' is of type: Letters
  11. expression: takesChristmasColor(A)
  12. tenums.nim(33, 20) Error: type mismatch: got <BC>
  13. but expected one of:
  14. proc takesChristmasColor(color: ChristmasColors)
  15. first type mismatch at position: 1
  16. required type for color: ChristmasColors
  17. but expression 'BC(C)' is of type: BC
  18. expression: takesChristmasColor(BC(C))
  19. '''
  20. """
  21. type
  22. Colors = enum Red, Green, Blue
  23. ChristmasColors = range[Red .. Green]
  24. Letters = enum A, B, C
  25. BC = range[B .. C]
  26. proc takesChristmasColor(color: ChristmasColors) = discard
  27. takesChristmasColor(Green)
  28. takesChristmasColor(A)
  29. takesChristmasColor(BC(C))