parent
558ecd1ca6
commit
cf5c3f2400
4 changed files with 21 additions and 19 deletions
|
|
@ -5,7 +5,7 @@ template reject(x) =
|
|||
static: assert(not compiles(x))
|
||||
|
||||
type
|
||||
Kind = enum k1 = 2, k2 = 33, k3 = 84, k4 = 278, k5 = 1000 # Holed enum work!
|
||||
Kind = enum k1 = 0, k2 = 33, k3 = 84, k4 = 278, k5 = 1000 # Holed enum work! #No they don't..
|
||||
KindObj = object
|
||||
case kind: Kind
|
||||
of k1, k2..k3: i32: int32
|
||||
|
|
@ -13,10 +13,10 @@ type
|
|||
else: str: string
|
||||
|
||||
IntObj = object
|
||||
case kind: int16
|
||||
of low(int16) .. -1: bad: string
|
||||
of 0: neutral: string
|
||||
of 1 .. high(int16): good: string
|
||||
case kind: uint8
|
||||
of low(uint8) .. 127: bad: string
|
||||
of 128'u8: neutral: string
|
||||
of 129 .. high(uint8): good: string
|
||||
|
||||
OtherKind = enum ok1, ok2, ok3, ok4, ok5
|
||||
NestedKindObj = object
|
||||
|
|
@ -76,24 +76,25 @@ reject: # elif branches are ignored
|
|||
elif kind == k4: discard
|
||||
else: discard KindObj(kind: kind, str: "3")
|
||||
|
||||
let intKind = 29'i16
|
||||
let intKind = 29'u8
|
||||
|
||||
accept:
|
||||
case intKind
|
||||
of low(int16) .. -1: discard IntObj(kind: intKind, bad: "bad")
|
||||
of 0: discard IntObj(kind: intKind, neutral: "neutral")
|
||||
of 1 .. high(int16): discard IntObj(kind: intKind, good: "good")
|
||||
of low(uint8) .. 127: discard IntObj(kind: intKind, bad: "bad")
|
||||
of 128'u8: discard IntObj(kind: intKind, neutral: "neutral")
|
||||
of 129 .. high(uint8): discard IntObj(kind: intKind, good: "good")
|
||||
|
||||
reject: # 0 leaks to else
|
||||
case intKind
|
||||
of low(int16) .. -1: discard IntObj(kind: intKind, bad: "bad")
|
||||
of 1 .. high(int16): discard IntObj(kind: intKind, good: "good")
|
||||
of low(uint8) .. 127: discard IntObj(kind: intKind, bad: "bad")
|
||||
of 129 .. high(uint8): discard IntObj(kind: intKind, good: "good")
|
||||
|
||||
accept:
|
||||
case intKind
|
||||
of low(int16) .. -1: discard IntObj(kind: intKind, bad: "bad")
|
||||
of 0: discard IntObj(kind: intKind, neutral: "neutral")
|
||||
of 10, 11 .. high(int16), 1 .. 9: discard IntObj(kind: intKind, good: "good")
|
||||
of low(uint8) .. 127: discard IntObj(kind: intKind, bad: "bad")
|
||||
of 128'u8: discard IntObj(kind: intKind, neutral: "neutral")
|
||||
of 139'u8, 140 .. high(uint8), 129'u8 .. 138'u8: discard IntObj(kind: intKind, good: "good")
|
||||
|
||||
|
||||
accept:
|
||||
case kind
|
||||
|
|
@ -148,7 +149,7 @@ reject:
|
|||
case kind:
|
||||
of k1: result = KindObj(kind: kind, i32: 1)
|
||||
else: discard
|
||||
|
||||
|
||||
type
|
||||
Kind3 = enum
|
||||
A, B, C, E
|
||||
|
|
@ -194,4 +195,4 @@ reject:
|
|||
discard
|
||||
|
||||
let x: range[0..15] = 1
|
||||
let o = Obj(x: x, field: 1)
|
||||
let o = Obj(x: x, field: 1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue