From 81125e2029fdd0d3a9c2931b066bfb72406a21ae Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Thu, 17 Oct 2019 20:02:59 +0200 Subject: [PATCH] [backport] add back a check that got accidentically removed; fixes #12379 (#12444) --- compiler/semtypes.nim | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index 896db5c3c..186161169 100644 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -635,6 +635,12 @@ proc semRecordCase(c: PContext, n: PNode, check: var IntSet, pos: var int, errorUndeclaredIdentifier(c, n.sons[0].info, typ.sym.name.s) elif not isOrdinalType(typ): localError(c.config, n.sons[0].info, "selector must be of an ordinal type, float or string") + elif firstOrd(c.config, typ) != 0: + localError(c.config, n.info, "low(" & $a.sons[0].sym.name.s & + ") must be 0 for discriminant") + elif lengthOrd(c.config, typ) > 0x00007FFF: + localError(c.config, n.info, "len($1) must be less than 32768" % a.sons[0].sym.name.s) + for i in 1 ..< len(n): var b = copyTree(n.sons[i]) addSon(a, b)