fixes 'lent T' inside object constructor [backport] (#18911)

* fixes 'lent T' inside object constructor [backport]

* progress
This commit is contained in:
Andreas Rumpf 2021-09-27 22:23:31 +02:00 • committed by GitHub
commit 576fece909
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 3 deletions

View file

@ -107,12 +107,13 @@ proc fitNode(c: PContext, formal: PType, arg: PNode; info: TLineInfo): PNode =
else:
result = fitNodePostMatch(c, formal, result)
proc fitNodeForLocalVar(c: PContext, formal: PType, arg: PNode; info: TLineInfo): PNode =
proc fitNodeConsiderViewType(c: PContext, formal: PType, arg: PNode; info: TLineInfo): PNode =
let a = fitNode(c, formal, arg, info)
if formal.kind in {tyVar, tyLent}:
#classifyViewType(formal) != noView:
result = newNodeIT(nkHiddenAddr, a.info, formal)
result.add a
formal.flags.incl tfVarIsPtr
else:
result = a