From 96c6c82d5592a7a19006c0fb161a74178cea9700 Mon Sep 17 00:00:00 2001 From: Araq Date: Sat, 4 Aug 2018 20:10:03 +0200 Subject: [PATCH] fixes #8425 --- compiler/semexprs.nim | 2 +- tests/sets/tsets.nim | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index d7a0d7b8b..c9f9eb33f 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -2127,7 +2127,7 @@ proc semSetConstr(c: PContext, n: PNode): PNode = n.sons[i] = semExprWithType(c, n.sons[i]) if typ == nil: typ = skipTypes(n.sons[i].typ, {tyGenericInst, tyVar, tyLent, tyOrdinal, tyAlias, tySink}) - if not isOrdinalType(typ): + if not isOrdinalType(typ, allowEnumWithHoles=true): localError(c.config, n.info, errOrdinalTypeExpected) typ = makeRangeType(c, 0, MaxSetElements-1, n.info) elif lengthOrd(c.config, typ) > MaxSetElements: diff --git a/tests/sets/tsets.nim b/tests/sets/tsets.nim index 96d5debc7..13a5f54e6 100644 --- a/tests/sets/tsets.nim +++ b/tests/sets/tsets.nim @@ -205,4 +205,12 @@ echo warnUninit in gNotes # 7555 doAssert {-1.int8, -2, -2}.card == 2 -doAssert {1, 2, 2, 3..5, 4..6}.card == 6 \ No newline at end of file +doAssert {1, 2, 2, 3..5, 4..6}.card == 6 + +type Foo = enum + Foo1 = 0 + Foo2 = 1 + Foo3 = 3 + +let x = { Foo1, Foo2 } +# bug #8425