Merge pull request #9959 from nc-x/better-error-message
Better error messages in enums which don't have ordinal types
This commit is contained in:
commit
3f917c8d91
1 changed files with 2 additions and 2 deletions
|
|
@ -91,7 +91,7 @@ proc semEnum(c: PContext, n: PNode, prev: PType): PType =
|
||||||
strVal = v.sons[1] # second tuple part is the string value
|
strVal = v.sons[1] # second tuple part is the string value
|
||||||
if skipTypes(strVal.typ, abstractInst).kind in {tyString, tyCString}:
|
if skipTypes(strVal.typ, abstractInst).kind in {tyString, tyCString}:
|
||||||
if not isOrdinalType(v.sons[0].typ, allowEnumWithHoles=true):
|
if not isOrdinalType(v.sons[0].typ, allowEnumWithHoles=true):
|
||||||
localError(c.config, v.sons[0].info, errOrdinalTypeExpected)
|
localError(c.config, v.sons[0].info, errOrdinalTypeExpected & "; given: " & typeToString(v.sons[0].typ, preferDesc))
|
||||||
x = getOrdValue(v.sons[0]) # first tuple part is the ordinal
|
x = getOrdValue(v.sons[0]) # first tuple part is the ordinal
|
||||||
else:
|
else:
|
||||||
localError(c.config, strVal.info, errStringLiteralExpected)
|
localError(c.config, strVal.info, errStringLiteralExpected)
|
||||||
|
|
@ -102,7 +102,7 @@ proc semEnum(c: PContext, n: PNode, prev: PType): PType =
|
||||||
x = counter
|
x = counter
|
||||||
else:
|
else:
|
||||||
if not isOrdinalType(v.typ, allowEnumWithHoles=true):
|
if not isOrdinalType(v.typ, allowEnumWithHoles=true):
|
||||||
localError(c.config, v.info, errOrdinalTypeExpected)
|
localError(c.config, v.info, errOrdinalTypeExpected & "; given: " & typeToString(v.typ, preferDesc))
|
||||||
x = getOrdValue(v)
|
x = getOrdValue(v)
|
||||||
if i != 1:
|
if i != 1:
|
||||||
if x != counter: incl(result.flags, tfEnumHasHoles)
|
if x != counter: incl(result.flags, tfEnumHasHoles)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue