JS: Fixed ICE on ptr assignment

This commit is contained in:
Yuriy Glukhov 2016-09-20 17:00:16 +03:00
commit 82b022ebc6
3 changed files with 29 additions and 6 deletions

View file

@ -1471,13 +1471,21 @@ proc genVarInit(p: PProc, v: PSym, n: PNode) =
useMagic(p, "nimCopy")
s = "nimCopy(null, $1, $2)" % [a.res, genTypeInfo(p, n.typ)]
of etyBaseIndex:
if (a.typ != etyBaseIndex): internalError(n.info, "genVarInit")
if {sfAddrTaken, sfGlobal} * v.flags != {}:
addf(p.body, "var $1 = [$2, $3];$n",
[v.loc.r, a.address, a.res])
let targetBaseIndex = {sfAddrTaken, sfGlobal} * v.flags == {}
if a.typ == etyBaseIndex:
if targetBaseIndex:
addf(p.body, "var $1 = $2, $1_Idx = $3;$n", [
v.loc.r, a.address, a.res])
else:
addf(p.body, "var $1 = [$2, $3];$n",
[v.loc.r, a.address, a.res])
else:
addf(p.body, "var $1 = $2; var $1_Idx = $3;$n", [
v.loc.r, a.address, a.res])
if targetBaseIndex:
let tmp = p.getTemp
addf(p.body, "var $1 = $2, $3 = $1[0], $3_Idx = $1[1];$n",
[tmp, a.res, v.loc.r])
else:
addf(p.body, "var $1 = $2;$n", [v.loc.r, a.res])
return
else:
s = a.res