This commit is contained in:
Andreas Rumpf 2021-06-29 15:34:39 +02:00 • committed by GitHub
commit 97fc95012d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 3 deletions

View file

@ -499,7 +499,7 @@ type
nfFirstWrite# this node is a first write nfFirstWrite# this node is a first write
TNodeFlags* = set[TNodeFlag] 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 tfVarargs, # procedure has C styled varargs
# tyArray type represeting a varargs list # tyArray type represeting a varargs list
tfNoSideEffect, # procedure type does not allow side effects tfNoSideEffect, # procedure type does not allow side effects
@ -566,6 +566,7 @@ type
# (for importc types); type is fully specified, allowing to compute # (for importc types); type is fully specified, allowing to compute
# sizeof, alignof, offsetof at CT # sizeof, alignof, offsetof at CT
tfExplicitCallConv tfExplicitCallConv
tfIsConstructor
TTypeFlags* = set[TTypeFlag] 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 = proc semSetConstr(c: PContext, n: PNode): PNode =
result = newNodeI(nkCurly, n.info) result = newNodeI(nkCurly, n.info)
result.typ = newTypeS(tySet, c) result.typ = newTypeS(tySet, c)
result.typ.flags.incl tfIsConstructor
if n.len == 0: if n.len == 0:
rawAddSon(result.typ, newTypeS(tyEmpty, c)) rawAddSon(result.typ, newTypeS(tyEmpty, c))
else: else:

View file

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