commit
03c4231951
3 changed files with 24 additions and 0 deletions
|
|
@ -90,6 +90,8 @@ proc semEnum(c: PContext, n: PNode, prev: PType): PType =
|
||||||
if sonsLen(v) == 2:
|
if sonsLen(v) == 2:
|
||||||
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):
|
||||||
|
localError(c.config, v.sons[0].info, errOrdinalTypeExpected)
|
||||||
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)
|
||||||
|
|
@ -99,6 +101,8 @@ proc semEnum(c: PContext, n: PNode, prev: PType): PType =
|
||||||
strVal = v
|
strVal = v
|
||||||
x = counter
|
x = counter
|
||||||
else:
|
else:
|
||||||
|
if not isOrdinalType(v.typ):
|
||||||
|
localError(c.config, v.info, errOrdinalTypeExpected)
|
||||||
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)
|
||||||
|
|
|
||||||
10
tests/errmsgs/t9908_01.nim
Normal file
10
tests/errmsgs/t9908_01.nim
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
discard """
|
||||||
|
errormsg: "ordinal type expected"
|
||||||
|
line: 10
|
||||||
|
"""
|
||||||
|
|
||||||
|
# https://github.com/nim-lang/Nim/issues/9908
|
||||||
|
|
||||||
|
type
|
||||||
|
X = enum
|
||||||
|
a = ("a", "b")
|
||||||
10
tests/errmsgs/t9908_02.nim
Normal file
10
tests/errmsgs/t9908_02.nim
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
discard """
|
||||||
|
errormsg: "ordinal type expected"
|
||||||
|
line: 10
|
||||||
|
"""
|
||||||
|
|
||||||
|
# https://github.com/nim-lang/Nim/pull/9909#issuecomment-445519287
|
||||||
|
|
||||||
|
type
|
||||||
|
E = enum
|
||||||
|
myVal = 80.9
|
||||||
Loading…
Add table
Add a link
Reference in a new issue