bugfix: subtle bug about 'var' parameters in templates
This commit is contained in:
parent
6ed18a8b24
commit
3620155d93
1 changed files with 7 additions and 4 deletions
|
|
@ -487,7 +487,7 @@ proc analyseIfAddressTaken(c: PContext, n: PNode): PNode =
|
||||||
if n.sons[0].kind == nkSym: incl(n.sons[0].sym.flags, sfAddrTaken)
|
if n.sons[0].kind == nkSym: incl(n.sons[0].sym.flags, sfAddrTaken)
|
||||||
result = newHiddenAddrTaken(c, n)
|
result = newHiddenAddrTaken(c, n)
|
||||||
else:
|
else:
|
||||||
result = newHiddenAddrTaken(c, n) # BUGFIX!
|
result = newHiddenAddrTaken(c, n)
|
||||||
|
|
||||||
proc analyseIfAddressTakenInCall(c: PContext, n: PNode) =
|
proc analyseIfAddressTakenInCall(c: PContext, n: PNode) =
|
||||||
checkMinSonsLen(n, 1)
|
checkMinSonsLen(n, 1)
|
||||||
|
|
@ -502,16 +502,19 @@ proc analyseIfAddressTakenInCall(c: PContext, n: PNode) =
|
||||||
|
|
||||||
if n.sons[0].kind == nkSym and n.sons[0].sym.magic in FakeVarParams:
|
if n.sons[0].kind == nkSym and n.sons[0].sym.magic in FakeVarParams:
|
||||||
# BUGFIX: check for L-Value still needs to be done for the arguments!
|
# BUGFIX: check for L-Value still needs to be done for the arguments!
|
||||||
|
# note sometimes this is eval'ed twice so we check for nkHiddenAddr here:
|
||||||
for i in countup(1, sonsLen(n) - 1):
|
for i in countup(1, sonsLen(n) - 1):
|
||||||
if i < sonsLen(t) and t.sons[i] != nil and
|
if i < sonsLen(t) and t.sons[i] != nil and
|
||||||
skipTypes(t.sons[i], abstractInst-{tyTypeDesc}).kind == tyVar:
|
skipTypes(t.sons[i], abstractInst-{tyTypeDesc}).kind == tyVar:
|
||||||
if isAssignable(c, n.sons[i]) notin {arLValue, arLocalLValue}:
|
if isAssignable(c, n.sons[i]) notin {arLValue, arLocalLValue}:
|
||||||
LocalError(n.sons[i].info, errVarForOutParamNeeded)
|
if n.sons[i].kind != nkHiddenAddr:
|
||||||
|
LocalError(n.sons[i].info, errVarForOutParamNeeded)
|
||||||
return
|
return
|
||||||
for i in countup(1, sonsLen(n) - 1):
|
for i in countup(1, sonsLen(n) - 1):
|
||||||
if i < sonsLen(t) and
|
if i < sonsLen(t) and
|
||||||
skipTypes(t.sons[i], abstractInst-{tyTypeDesc}).kind == tyVar:
|
skipTypes(t.sons[i], abstractInst-{tyTypeDesc}).kind == tyVar:
|
||||||
n.sons[i] = analyseIfAddressTaken(c, n.sons[i])
|
if n.sons[i].kind != nkHiddenAddr:
|
||||||
|
n.sons[i] = analyseIfAddressTaken(c, n.sons[i])
|
||||||
|
|
||||||
include semmagic
|
include semmagic
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue