File: tcaseexpr1.nim

package info (click to toggle)
nim 2.2.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,951,164 kB
  • sloc: sh: 24,599; ansic: 1,771; python: 1,493; makefile: 1,013; sql: 298; asm: 141; xml: 13
file content (39 lines) | stat: -rw-r--r-- 488 bytes parent folder | download | duplicates (2)
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
34
35
36
37
38
39
discard """
  cmd: "nim check $options $file"
  action: "reject"
  nimout: '''
tcaseexpr1.nim(33, 10) Error: not all cases are covered; missing: {C}
tcaseexpr1.nim(39, 12) Error: type mismatch: got <string> but expected 'int literal(10)'
'''
"""











# line 20
type
  E = enum A, B, C

proc foo(x: int): auto =
  return case x
    of 1..9: "digit"
    else: "number"

var r = foo(10)

var x = C

var t1 = case x:
  of A: "a"
  of B: "b"

var t2 = case x:
  of A: 10
  of B, C: "23"