summary refs log tree commit diff stats
path: root/tests/range/tenums.nim
blob: 3cdf06fe291efe8040afe3082c68fbcf1960ac76 (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
31
32
33
discard """
  cmd: "nim check --hints:off $file"
  errormsg: "type mismatch: got <BC>"
  nimout: '''
tenums.nim(32, 20) Error: type mismatch: got <Letters>
but expected one of:
proc takesChristmasColor(color: ChristmasColors)
  first type mismatch at position: 1
  required type for color: ChristmasColors
  but expression 'A' is of type: Letters

expression: takesChristmasColor(A)
tenums.nim(33, 20) Error: type mismatch: got <BC>
but expected one of:
proc takesChristmasColor(color: ChristmasColors)
  first type mismatch at position: 1
  required type for color: ChristmasColors
  but expression 'BC(C)' is of type: BC

expression: takesChristmasColor(BC(C))
'''
"""

type
  Colors = enum Red, Green, Blue
  ChristmasColors = range[Red .. Green]
  Letters = enum A, B, C
  BC = range[B .. C]

proc takesChristmasColor(color: ChristmasColors) = discard
takesChristmasColor(Green)
takesChristmasColor(A)
takesChristmasColor(BC(C))