fixes #14079 [backport:1.2] (#14163)

This commit is contained in:
Andreas Rumpf 2020-04-29 21:58:59 +02:00 • committed by GitHub
commit d9e907c0e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 36 additions and 7 deletions

View file

@ -854,7 +854,8 @@ proc track(tracked: PEffects, n: PNode) =
when false: cstringCheck(tracked, n)
if tracked.owner.kind != skMacro:
createTypeBoundOps(tracked, n[0].typ, n.info)
checkForSink(tracked.config, tracked.owner, n[1])
if n[0].kind != nkSym or not isLocalVar(tracked, n[0].sym):
checkForSink(tracked.config, tracked.owner, n[1])
of nkVarSection, nkLetSection:
for child in n:
let last = lastSon(child)

View file

@ -548,7 +548,8 @@ proc allowsNilDeprecated(c: TCandidate, f: PType): TTypeRelation =
result = isNone
proc inconsistentVarTypes(f, a: PType): bool {.inline.} =
result = f.kind != a.kind and (f.kind in {tyVar, tyLent} or a.kind in {tyVar, tyLent})
result = f.kind != a.kind and
(f.kind in {tyVar, tyLent, tySink} or a.kind in {tyVar, tyLent, tySink})
proc procParamTypeRel(c: var TCandidate, f, a: PType): TTypeRelation =
## For example we have:

View file

@ -48,8 +48,7 @@ proc checkForSink*(config: ConfigRef; owner: PSym; arg: PNode) =
# we only report every potential 'sink' parameter only once:
incl arg.sym.flags, sfWasForwarded
message(config, arg.info, hintPerformance,
("could not turn '$1' to a sink parameter " &
"because '$2' was forward declared") % [arg.sym.name.s, owner.name.s])
"could not turn '$1' to a sink parameter" % [arg.sym.name.s])
#echo config $ arg.info, " candidate for a sink parameter here"
of nkStmtList, nkStmtListExpr, nkBlockStmt, nkBlockExpr:
if not isEmptyType(arg.typ):