diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index f90ef48701..ae118159cf 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -1047,7 +1047,7 @@ proc semIndirectOp(c: PContext, n: PNode, flags: TExprFlags; expectedType: PType if s != nil: setGenericParams(c, n[0]) return semDirectOp(c, n, flags, expectedType) - elif isSymChoice(n[0]): + elif isSymChoice(n[0]) and nfDotField notin n.flags: # overloaded generic procs e.g. newSeq[int] can end up here return semDirectOp(c, n, flags, expectedType) diff --git a/tests/enum/t21863.nim b/tests/enum/t21863.nim new file mode 100644 index 0000000000..d0d8b1fcd8 --- /dev/null +++ b/tests/enum/t21863.nim @@ -0,0 +1,28 @@ +discard """ +cmd: "nim check --hints:off $file" +action: reject +nimout: ''' +t21863.nim(28, 16) Error: undeclared field: 'A' + found 'A' [enumField declared in t21863.nim(24, 18)] + found 'A' [enumField declared in t21863.nim(25, 18)] +t21863.nim(28, 16) Error: undeclared field: '.' +t21863.nim(28, 16) Error: undeclared field: '.' +t21863.nim(28, 16) Error: expression '' has no type (or is ambiguous) +''' +""" + + + + + + + + + +block: + type + EnumA = enum A, B + EnumB = enum A + EnumC = enum C + + discard EnumC.A