mirror of
https://github.com/nim-lang/Nim.git
synced 2026-07-19 23:41:29 +00:00
newruntime: bugfixes
This commit is contained in:
@@ -354,7 +354,7 @@ proc genSink(c: Con; t: PType; dest, ri: PNode): PNode =
|
||||
# in rare cases only =destroy exists but no sink or assignment
|
||||
# (see Pony object in tmove_objconstr.nim)
|
||||
# we generate a fast assignment in this case:
|
||||
result = newTree(nkFastAsgn, dest, ri)
|
||||
result = newTree(nkFastAsgn, dest)
|
||||
|
||||
proc genCopy(c: Con; t: PType; dest, ri: PNode): PNode =
|
||||
if tfHasOwned in t.flags:
|
||||
@@ -598,6 +598,9 @@ proc moveOrCopy(dest, ri: PNode; c: var Con): PNode =
|
||||
else:
|
||||
ri2[i] = pArg(ri[i], c, isSink = true)
|
||||
result.add ri2
|
||||
of nkNilLit:
|
||||
result = genSink(c, dest.typ, dest, ri)
|
||||
result.add ri
|
||||
of nkSym:
|
||||
if isSinkParam(ri.sym):
|
||||
# Rule 3: `=sink`(x, z); wasMoved(z)
|
||||
|
||||
@@ -1518,6 +1518,8 @@ proc asgnToResultVar(c: PContext, n, le, ri: PNode) {.inline.} =
|
||||
n.sons[1] = takeImplicitAddr(c, ri, x.typ.kind == tyLent)
|
||||
x.typ.flags.incl tfVarIsPtr
|
||||
#echo x.info, " setting it for this type ", typeToString(x.typ), " ", n.info
|
||||
|
||||
proc asgnToResult(c: PContext, n, le, ri: PNode) =
|
||||
# Special typing rule: do not allow to pass 'owned T' to 'T' in 'result = x':
|
||||
if ri.typ != nil and ri.typ.skipTypes(abstractInst).kind == tyOwned and
|
||||
le.typ != nil and le.typ.skipTypes(abstractInst).kind != tyOwned:
|
||||
@@ -1614,6 +1616,7 @@ proc semAsgn(c: PContext, n: PNode; mode=asgnNormal): PNode =
|
||||
c.p.owner.typ.sons[0] = rhsTyp
|
||||
else:
|
||||
typeMismatch(c.config, n.info, lhs.typ, rhsTyp)
|
||||
asgnToResult(c, n, n.sons[0], n.sons[1])
|
||||
|
||||
n.sons[1] = fitNode(c, le, rhs, goodLineInfo(n[1]))
|
||||
liftTypeBoundOps(c, lhs.typ, lhs.info)
|
||||
|
||||
@@ -1277,7 +1277,7 @@ proc typeAllowedAux(marker: var IntSet, typ: PType, kind: TSymKind,
|
||||
# prevent cascading errors:
|
||||
result = nil
|
||||
of tyOwned:
|
||||
if t.len == 1 and t.sons[0].kind in {tyRef, tyPtr}:
|
||||
if t.len == 1 and t.sons[0].skipTypes(abstractInst).kind in {tyRef, tyPtr, tyProc}:
|
||||
result = typeAllowedAux(marker, t.lastSon, skVar, flags+{taHeap})
|
||||
else:
|
||||
result = t
|
||||
|
||||
Reference in New Issue
Block a user