parent
2ea7287217
commit
f65f760dee
5 changed files with 18 additions and 3 deletions
|
|
@ -1238,6 +1238,8 @@ proc gsub(g: var TSrcGen, n: PNode, c: TContext, fromStmtList = false) =
|
||||||
putWithSpace(g, tkBind, "bind")
|
putWithSpace(g, tkBind, "bind")
|
||||||
gsub(g, n, 0)
|
gsub(g, n, 0)
|
||||||
of nkCheckedFieldExpr, nkHiddenAddr, nkHiddenDeref, nkStringToCString, nkCStringToString:
|
of nkCheckedFieldExpr, nkHiddenAddr, nkHiddenDeref, nkStringToCString, nkCStringToString:
|
||||||
|
if renderIds in g.flags:
|
||||||
|
putWithSpace(g, tkAddr, $n.kind)
|
||||||
gsub(g, n, 0)
|
gsub(g, n, 0)
|
||||||
of nkLambda:
|
of nkLambda:
|
||||||
putWithSpace(g, tkProc, "proc")
|
putWithSpace(g, tkProc, "proc")
|
||||||
|
|
|
||||||
|
|
@ -100,6 +100,15 @@ proc fitNode(c: PContext, formal: PType, arg: PNode; info: TLineInfo): PNode =
|
||||||
else:
|
else:
|
||||||
result = fitNodePostMatch(c, formal, result)
|
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,
|
proc inferWithMetatype(c: PContext, formal: PType,
|
||||||
arg: PNode, coerceDistincts = false): PNode
|
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.} =
|
proc asgnToResultVar(c: PContext, n, le, ri: PNode) {.inline.} =
|
||||||
if le.kind == nkHiddenDeref:
|
if le.kind == nkHiddenDeref:
|
||||||
var x = le[0]
|
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[0] = x # 'result[]' --> 'result'
|
||||||
n[1] = takeImplicitAddr(c, ri, x.typ.kind == tyLent)
|
n[1] = takeImplicitAddr(c, ri, x.typ.kind == tyLent)
|
||||||
x.typ.flags.incl tfVarIsPtr
|
x.typ.flags.incl tfVarIsPtr
|
||||||
|
|
|
||||||
|
|
@ -526,7 +526,7 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
|
||||||
else:
|
else:
|
||||||
# BUGFIX: ``fitNode`` is needed here!
|
# BUGFIX: ``fitNode`` is needed here!
|
||||||
# check type compatibility between def.typ and typ
|
# 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)
|
#changeType(def.skipConv, typ, check=true)
|
||||||
else:
|
else:
|
||||||
typ = def.typ.skipTypes({tyStatic, tySink}).skipIntLit(c.idgen)
|
typ = def.typ.skipTypes({tyStatic, tySink}).skipIntLit(c.idgen)
|
||||||
|
|
|
||||||
|
|
@ -519,13 +519,17 @@ const
|
||||||
proc isConstSym(s: PSym): bool =
|
proc isConstSym(s: PSym): bool =
|
||||||
result = s.kind in {skConst, skLet} or isConstParam(s)
|
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) =
|
proc borrowFrom(c: var Partitions; dest: PSym; src: PNode) =
|
||||||
const
|
const
|
||||||
url = "see https://nim-lang.github.io/Nim/manual_experimental.html#view-types-algorithm-path-expressions for details"
|
url = "see https://nim-lang.github.io/Nim/manual_experimental.html#view-types-algorithm-path-expressions for details"
|
||||||
|
|
||||||
let s = pathExpr(src, c.owner)
|
let s = pathExpr(src, c.owner)
|
||||||
if s == nil:
|
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:
|
elif s.kind == nkSym:
|
||||||
if dest.kind == skResult:
|
if dest.kind == skResult:
|
||||||
if s.sym.kind != skParam or s.sym.position != 0:
|
if s.sym.kind != skParam or s.sym.position != 0:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue