mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-08 14:03:23 +00:00
* fixes #21887; Type conversion on overloaded enum field does not always call * remove comments * add a test case * restrict it to enums
This commit is contained in:
@@ -349,6 +349,9 @@ proc semConv(c: PContext, n: PNode; expectedType: PType = nil): PNode =
|
||||
targetType.skipTypes(abstractPtrs).kind == tyObject:
|
||||
localError(c.config, n.info, "object construction uses ':', not '='")
|
||||
var op = semExprWithType(c, n[1])
|
||||
if op.kind == nkClosedSymChoice and op.len > 0 and
|
||||
op[0].sym.kind == skEnumField: # resolves overloadedable enums
|
||||
op = ambiguousSymChoice(c, n, op)
|
||||
if targetType.kind != tyGenericParam and targetType.isMetaType:
|
||||
let final = inferWithMetatype(c, targetType, op, true)
|
||||
result.add final
|
||||
|
||||
@@ -118,3 +118,11 @@ block: # test with macros/templates
|
||||
doAssert isOneMS(e2)
|
||||
doAssert isOneT(e1)
|
||||
doAssert isOneT(e2)
|
||||
|
||||
block: # bug #21908
|
||||
type
|
||||
EnumA = enum A = 300, B
|
||||
EnumB = enum A = 10
|
||||
EnumC = enum C
|
||||
|
||||
doAssert typeof(EnumC(A)) is EnumC
|
||||
|
||||
Reference in New Issue
Block a user