parent
69aeb86f49
commit
3659fec725
2 changed files with 17 additions and 11 deletions
|
|
@ -1290,12 +1290,9 @@ proc takeImplicitAddr(c: PContext, n: PNode): 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.sons[0]
|
var x = le.sons[0]
|
||||||
if x.typ.kind == tyVar and x.kind == nkSym:
|
if x.typ.kind == tyVar and x.kind == nkSym and x.sym.kind == skResult:
|
||||||
if x.sym.kind == skResult:
|
|
||||||
n.sons[0] = x # 'result[]' --> 'result'
|
n.sons[0] = x # 'result[]' --> 'result'
|
||||||
n.sons[1] = takeImplicitAddr(c, ri)
|
n.sons[1] = takeImplicitAddr(c, ri)
|
||||||
if x.sym.kind != skParam:
|
|
||||||
# XXX This is hacky. See bug #4910.
|
|
||||||
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
|
||||||
|
|
||||||
|
|
@ -1449,14 +1446,15 @@ proc semYieldVarResult(c: PContext, n: PNode, restype: PType) =
|
||||||
var t = skipTypes(restype, {tyGenericInst, tyAlias})
|
var t = skipTypes(restype, {tyGenericInst, tyAlias})
|
||||||
case t.kind
|
case t.kind
|
||||||
of tyVar:
|
of tyVar:
|
||||||
|
t.flags.incl tfVarIsPtr # bugfix for #4048, #4910, #6892
|
||||||
if n.sons[0].kind in {nkHiddenStdConv, nkHiddenSubConv}:
|
if n.sons[0].kind in {nkHiddenStdConv, nkHiddenSubConv}:
|
||||||
n.sons[0] = n.sons[0].sons[1]
|
n.sons[0] = n.sons[0].sons[1]
|
||||||
|
|
||||||
n.sons[0] = takeImplicitAddr(c, n.sons[0])
|
n.sons[0] = takeImplicitAddr(c, n.sons[0])
|
||||||
of tyTuple:
|
of tyTuple:
|
||||||
for i in 0..<t.sonsLen:
|
for i in 0..<t.sonsLen:
|
||||||
var e = skipTypes(t.sons[i], {tyGenericInst, tyAlias})
|
var e = skipTypes(t.sons[i], {tyGenericInst, tyAlias})
|
||||||
if e.kind == tyVar:
|
if e.kind == tyVar:
|
||||||
|
e.flags.incl tfVarIsPtr # bugfix for #4048, #4910, #6892
|
||||||
if n.sons[0].kind == nkPar:
|
if n.sons[0].kind == nkPar:
|
||||||
n.sons[0].sons[i] = takeImplicitAddr(c, n.sons[0].sons[i])
|
n.sons[0].sons[i] = takeImplicitAddr(c, n.sons[0].sons[i])
|
||||||
elif n.sons[0].kind in {nkHiddenStdConv, nkHiddenSubConv} and
|
elif n.sons[0].kind in {nkHiddenStdConv, nkHiddenSubConv} and
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,18 @@ proc getSubsystem*[T](): ptr T {.
|
||||||
let input: ptr Input = getSubsystem[Input]()
|
let input: ptr Input = getSubsystem[Input]()
|
||||||
|
|
||||||
|
|
||||||
# bug #4910
|
# bugs #4910, #6892
|
||||||
|
proc modify(x: var int) =
|
||||||
|
x = 123
|
||||||
|
|
||||||
proc foo() =
|
proc foo() =
|
||||||
var ts: array[10, int]
|
var ts: array[2, int]
|
||||||
for t in mitems(ts):
|
for t in mitems(ts):
|
||||||
t = 123
|
discard
|
||||||
|
|
||||||
|
for t in mitems(ts):
|
||||||
|
modify(t)
|
||||||
|
|
||||||
|
for i, t in mpairs(ts):
|
||||||
|
modify(t)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue