parent
0ad601d3c1
commit
6163bdd279
2 changed files with 21 additions and 6 deletions
|
|
@ -1667,11 +1667,14 @@ 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.kind == nkSym and x.sym.kind == skResult and (x.typ.kind in {tyVar, tyLent} or classifyViewType(x.typ) != noView):
|
if x.kind == nkSym:
|
||||||
n[0] = x # 'result[]' --> 'result'
|
if x.sym.kind == skResult and (x.typ.kind in {tyVar, tyLent} or classifyViewType(x.typ) != noView):
|
||||||
n[1] = takeImplicitAddr(c, ri, x.typ.kind == tyLent)
|
n[0] = x # 'result[]' --> 'result'
|
||||||
x.typ.flags.incl tfVarIsPtr
|
n[1] = takeImplicitAddr(c, ri, x.typ.kind == tyLent)
|
||||||
#echo x.info, " setting it for this type ", typeToString(x.typ), " ", n.info
|
x.typ.flags.incl tfVarIsPtr
|
||||||
|
#echo x.info, " setting it for this type ", typeToString(x.typ), " ", n.info
|
||||||
|
elif sfGlobal in x.sym.flags:
|
||||||
|
x.typ.flags.incl tfVarIsPtr
|
||||||
|
|
||||||
proc borrowCheck(c: PContext, n, le, ri: PNode) =
|
proc borrowCheck(c: PContext, n, le, ri: PNode) =
|
||||||
const
|
const
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,8 @@ discard """
|
||||||
3
|
3
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
3'''
|
3
|
||||||
|
15'''
|
||||||
targets: "c cpp"
|
targets: "c cpp"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
@ -26,3 +27,14 @@ proc main(s: seq[int]) =
|
||||||
take x
|
take x
|
||||||
|
|
||||||
main(@[11, 22, 33])
|
main(@[11, 22, 33])
|
||||||
|
|
||||||
|
var x: int
|
||||||
|
|
||||||
|
proc foo(x: var int): var int =
|
||||||
|
once: x = 42
|
||||||
|
return x
|
||||||
|
|
||||||
|
var y: var int = foo(x)
|
||||||
|
y = 15
|
||||||
|
echo foo(x)
|
||||||
|
# bug #16132
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue