implemented case expressions

This commit is contained in:
Zahary Karadjov
2012-10-01 23:48:37 +03:00
parent 92f70b08f9
commit 770d4a997e
8 changed files with 137 additions and 24 deletions

View File

@@ -0,0 +1,30 @@
discard """
file: "tcaseexpr1.nim"
line: 23
errormsg: "not all cases are covered"
line: 29
errormsg: "type mismatch: got (string) but expected 'int'"
"""
type
E = enum A, B, C
proc foo(x): 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"