From e737b47ee148c77184ad985573d1cfc329b2fcab Mon Sep 17 00:00:00 2001 From: Hans Raaf Date: Sun, 7 Feb 2016 00:30:21 +0100 Subject: [PATCH] Fix for index check in PHP code. --- compiler/jsgen.nim | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim index 5da61e3821..21bd45d710 100644 --- a/compiler/jsgen.nim +++ b/compiler/jsgen.nim @@ -891,7 +891,10 @@ proc genArrayAddr(p: PProc, n: PNode, r: var TCompRes) = else: first = 0 if optBoundsCheck in p.options and not isConstExpr(m.sons[1]): useMagic(p, "chckIndx") - r.res = "chckIndx($1, $2, $3.length)-$2" % [b.res, rope(first), a.res] + if p.target == targetPHP: + r.res = "chckIndx($1, $2, count($3))-$2" % [b.res, rope(first), a.res] + else: + r.res = "chckIndx($1, $2, $3.length)-$2" % [b.res, rope(first), a.res] elif first != 0: r.res = "($1)-$2" % [b.res, rope(first)] else: