This commit is contained in:
Andreas Rumpf
2021-06-29 15:34:39 +02:00
committed by GitHub
parent 6387e28963
commit 97fc95012d
3 changed files with 10 additions and 3 deletions

View File

@@ -499,7 +499,7 @@ type
nfFirstWrite# this node is a first write
TNodeFlags* = set[TNodeFlag]
TTypeFlag* = enum # keep below 32 for efficiency reasons (now: ~40)
TTypeFlag* = enum # keep below 32 for efficiency reasons (now: 43)
tfVarargs, # procedure has C styled varargs
# tyArray type represeting a varargs list
tfNoSideEffect, # procedure type does not allow side effects
@@ -566,6 +566,7 @@ type
# (for importc types); type is fully specified, allowing to compute
# sizeof, alignof, offsetof at CT
tfExplicitCallConv
tfIsConstructor
TTypeFlags* = set[TTypeFlag]

View File

@@ -2412,6 +2412,7 @@ proc semWhen(c: PContext, n: PNode, semCheck = true): PNode =
proc semSetConstr(c: PContext, n: PNode): PNode =
result = newNodeI(nkCurly, n.info)
result.typ = newTypeS(tySet, c)
result.typ.flags.incl tfIsConstructor
if n.len == 0:
rawAddSon(result.typ, newTypeS(tyEmpty, c))
else:

View File

@@ -1341,8 +1341,13 @@ proc typeRel(c: var TCandidate, f, aOrig: PType,
result = isSubtype
else:
result = typeRel(c, f[0], a[0], flags)
if result <= isConvertible:
result = isNone # BUGFIX!
if result < isGeneric:
if result <= isConvertible:
result = isNone
elif tfIsConstructor notin a.flags:
# set constructors are a bit special...
result = isNone
of tyPtr, tyRef:
skipOwned(a)
if a.kind == f.kind: