This commit is contained in:
Andreas Rumpf
2021-09-03 15:18:55 +02:00
committed by GitHub
parent 0635697a89
commit 06ff0e9624
2 changed files with 17 additions and 2 deletions

View File

@@ -107,6 +107,12 @@ proc semGenericStmtSymbol(c: PContext, n: PNode, s: PSym,
else:
result = n
onUse(n.info, s)
of skEnumField:
if overloadableEnums in c.features:
result = symChoice(c, n, s, scOpen)
else:
result = newSymNode(s, n.info)
onUse(n.info, s)
else:
result = newSymNode(s, n.info)
onUse(n.info, s)
@@ -407,7 +413,7 @@ proc semGenericStmt(c: PContext, n: PNode,
a[^1] = semGenericStmt(c, a[^1], flags, ctx)
for j in 0..<a.len-2:
addTempDecl(c, getIdentNode(c, a[j]), varKind)
else:
else:
illFormedAst(a, c.config)
of nkGenericParams:
for i in 0..<n.len:

View File

@@ -1,6 +1,7 @@
discard """
output: '''B
0'''
0
E2-B'''
joinable: false
"""
@@ -75,3 +76,11 @@ block: # https://github.com/nim-lang/RFCs/issues/8
doAssert x == 0
doAssert hA3 == 1
doAssert hA4 == 1
# bug #18769
proc g3[T](x: T, e: E2): int =
case e
of value1: echo "E2-A" # Error: type mismatch: got 'E1' for 'value1' but expected 'E2 = enum'
of value2: echo "E2-B"
let v5 = g3(99, E2.value2)