parseEnum_regression (#14150)

Co-authored-by: cooldome <ariabushenko@bk.ru>
This commit is contained in:
cooldome 2020-04-28 18:56:50 +01:00 • committed by GitHub
commit 3b5a504692
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 3 deletions

View file

@ -99,6 +99,7 @@ proc semEnum(c: PContext, n: PNode, prev: PType): PType =
if not isOrdinalType(v[0].typ, allowEnumWithHoles=true):
localError(c.config, v[0].info, errOrdinalTypeExpected & "; given: " & typeToString(v[0].typ, preferDesc))
x = toInt64(getOrdValue(v[0])) # first tuple part is the ordinal
n[i][1][0] = newIntTypeNode(x, getSysType(c.graph, unknownLineInfo, tyInt))
else:
localError(c.config, strVal.info, errStringLiteralExpected)
else:
@ -110,6 +111,7 @@ proc semEnum(c: PContext, n: PNode, prev: PType): PType =
if not isOrdinalType(v.typ, allowEnumWithHoles=true):
localError(c.config, v.info, errOrdinalTypeExpected & "; given: " & typeToString(v.typ, preferDesc))
x = toInt64(getOrdValue(v))
n[i][1] = newIntTypeNode(x, getSysType(c.graph, unknownLineInfo, tyInt))
if i != 1:
if x != counter: incl(result.flags, tfEnumHasHoles)
if x < counter: