This commit is contained in:
Araq 2017-10-14 22:34:19 +02:00
commit a75f3b3661
2 changed files with 15 additions and 4 deletions

View file

@ -1296,9 +1296,12 @@ 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 and x.sym.kind == skResult: if x.typ.kind == tyVar and x.kind == nkSym:
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

View file

@ -21,3 +21,11 @@ proc getSubsystem*[T](): ptr T {.
let input: ptr Input = getSubsystem[Input]() let input: ptr Input = getSubsystem[Input]()
# bug #4910
proc foo() =
var ts: array[10, int]
for t in mitems(ts):
t = 123