newruntime: bugfixes
This commit is contained in:
parent
b0e236674c
commit
663b1f2c96
3 changed files with 8 additions and 2 deletions
|
|
@ -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
|
# in rare cases only =destroy exists but no sink or assignment
|
||||||
# (see Pony object in tmove_objconstr.nim)
|
# (see Pony object in tmove_objconstr.nim)
|
||||||
# we generate a fast assignment in this case:
|
# 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 =
|
proc genCopy(c: Con; t: PType; dest, ri: PNode): PNode =
|
||||||
if tfHasOwned in t.flags:
|
if tfHasOwned in t.flags:
|
||||||
|
|
@ -598,6 +598,9 @@ proc moveOrCopy(dest, ri: PNode; c: var Con): PNode =
|
||||||
else:
|
else:
|
||||||
ri2[i] = pArg(ri[i], c, isSink = true)
|
ri2[i] = pArg(ri[i], c, isSink = true)
|
||||||
result.add ri2
|
result.add ri2
|
||||||
|
of nkNilLit:
|
||||||
|
result = genSink(c, dest.typ, dest, ri)
|
||||||
|
result.add ri
|
||||||
of nkSym:
|
of nkSym:
|
||||||
if isSinkParam(ri.sym):
|
if isSinkParam(ri.sym):
|
||||||
# Rule 3: `=sink`(x, z); wasMoved(z)
|
# 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)
|
n.sons[1] = takeImplicitAddr(c, ri, x.typ.kind == tyLent)
|
||||||
x.typ.flags.incl tfVarIsPtr
|
x.typ.flags.incl tfVarIsPtr
|
||||||
#echo x.info, " setting it for this type ", typeToString(x.typ), " ", n.info
|
#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':
|
# 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
|
if ri.typ != nil and ri.typ.skipTypes(abstractInst).kind == tyOwned and
|
||||||
le.typ != nil and le.typ.skipTypes(abstractInst).kind != tyOwned:
|
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
|
c.p.owner.typ.sons[0] = rhsTyp
|
||||||
else:
|
else:
|
||||||
typeMismatch(c.config, n.info, lhs.typ, rhsTyp)
|
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]))
|
n.sons[1] = fitNode(c, le, rhs, goodLineInfo(n[1]))
|
||||||
liftTypeBoundOps(c, lhs.typ, lhs.info)
|
liftTypeBoundOps(c, lhs.typ, lhs.info)
|
||||||
|
|
|
||||||
|
|
@ -1277,7 +1277,7 @@ proc typeAllowedAux(marker: var IntSet, typ: PType, kind: TSymKind,
|
||||||
# prevent cascading errors:
|
# prevent cascading errors:
|
||||||
result = nil
|
result = nil
|
||||||
of tyOwned:
|
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})
|
result = typeAllowedAux(marker, t.lastSon, skVar, flags+{taHeap})
|
||||||
else:
|
else:
|
||||||
result = t
|
result = t
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue