mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
@@ -1238,6 +1238,8 @@ proc gsub(g: var TSrcGen, n: PNode, c: TContext, fromStmtList = false) =
|
||||
putWithSpace(g, tkBind, "bind")
|
||||
gsub(g, n, 0)
|
||||
of nkCheckedFieldExpr, nkHiddenAddr, nkHiddenDeref, nkStringToCString, nkCStringToString:
|
||||
if renderIds in g.flags:
|
||||
putWithSpace(g, tkAddr, $n.kind)
|
||||
gsub(g, n, 0)
|
||||
of nkLambda:
|
||||
putWithSpace(g, tkProc, "proc")
|
||||
|
||||
@@ -100,6 +100,15 @@ 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 =
|
||||
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
|
||||
else:
|
||||
result = a
|
||||
|
||||
proc inferWithMetatype(c: PContext, formal: PType,
|
||||
arg: PNode, coerceDistincts = false): PNode
|
||||
|
||||
|
||||
@@ -1643,7 +1643,7 @@ proc takeImplicitAddr(c: PContext, n: PNode; isLent: bool): PNode =
|
||||
proc asgnToResultVar(c: PContext, n, le, ri: PNode) {.inline.} =
|
||||
if le.kind == nkHiddenDeref:
|
||||
var x = le[0]
|
||||
if (x.typ.kind in {tyVar, tyLent} or classifyViewType(x.typ) != noView) and x.kind == nkSym and x.sym.kind == skResult:
|
||||
if x.kind == nkSym and x.sym.kind == skResult and (x.typ.kind in {tyVar, tyLent} or classifyViewType(x.typ) != noView):
|
||||
n[0] = x # 'result[]' --> 'result'
|
||||
n[1] = takeImplicitAddr(c, ri, x.typ.kind == tyLent)
|
||||
x.typ.flags.incl tfVarIsPtr
|
||||
|
||||
@@ -526,7 +526,7 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
|
||||
else:
|
||||
# BUGFIX: ``fitNode`` is needed here!
|
||||
# check type compatibility between def.typ and typ
|
||||
def = fitNode(c, typ, def, def.info)
|
||||
def = fitNodeForLocalVar(c, typ, def, def.info)
|
||||
#changeType(def.skipConv, typ, check=true)
|
||||
else:
|
||||
typ = def.typ.skipTypes({tyStatic, tySink}).skipIntLit(c.idgen)
|
||||
|
||||
@@ -519,13 +519,17 @@ const
|
||||
proc isConstSym(s: PSym): bool =
|
||||
result = s.kind in {skConst, skLet} or isConstParam(s)
|
||||
|
||||
proc toString(n: PNode): string =
|
||||
if n.kind == nkEmpty: result = "<empty>"
|
||||
else: result = $n
|
||||
|
||||
proc borrowFrom(c: var Partitions; dest: PSym; src: PNode) =
|
||||
const
|
||||
url = "see https://nim-lang.github.io/Nim/manual_experimental.html#view-types-algorithm-path-expressions for details"
|
||||
|
||||
let s = pathExpr(src, c.owner)
|
||||
if s == nil:
|
||||
localError(c.g.config, src.info, "cannot borrow from " & $src & ", it is not a path expression; " & url)
|
||||
localError(c.g.config, src.info, "cannot borrow from " & src.toString & ", it is not a path expression; " & url)
|
||||
elif s.kind == nkSym:
|
||||
if dest.kind == skResult:
|
||||
if s.sym.kind != skParam or s.sym.position != 0:
|
||||
|
||||
Reference in New Issue
Block a user