only allow enums to overload enums + extra test (#20126)

mirror behavior without overloadableEnums
This commit is contained in:
metagn 2022-09-03 10:53:31 +03:00 • committed by GitHub
commit a6189fbb98
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 2 deletions

View file

@ -2798,7 +2798,7 @@ proc enumFieldSymChoice(c: PContext, n: PNode, s: PSym): PNode =
var i = 0
var a = initOverloadIter(o, c, n)
while a != nil:
if a.kind in OverloadableSyms-{skModule}:
if a.kind == skEnumField:
inc(i)
if i > 1: break
a = nextOverloadIter(o, c, n)
@ -2814,7 +2814,7 @@ proc enumFieldSymChoice(c: PContext, n: PNode, s: PSym): PNode =
result = newNodeIT(nkClosedSymChoice, info, newTypeS(tyNone, c))
a = initOverloadIter(o, c, n)
while a != nil:
if a.kind in OverloadableSyms-{skModule}:
if a.kind == skEnumField:
incl(a.flags, sfUsed)
markOwnerModuleAsUsed(c, a)
result.add newSymNode(a, info)