summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2017-06-29 18:48:24 +0200
committerAndreas Rumpf <rumpf_a@web.de>2017-06-29 18:48:24 +0200
commit6f29041f0910e088e0e96f77e5aae8a39edbe5c5 (patch)
tree9b63e069b664847ab812a5543c6f0ebefe491705
parent5d6c2f89de31187b0b3f1e165037b7dea4dad133 (diff)
downloadNim-6f29041f0910e088e0e96f77e5aae8a39edbe5c5.tar.gz
fixes #5563
-rw-r--r--compiler/jsgen.nim6
1 files changed, 3 insertions, 3 deletions
diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim
index 8a73fb8a8..3e5cad9fd 100644
--- a/compiler/jsgen.nim
+++ b/compiler/jsgen.nim
@@ -1047,15 +1047,15 @@ proc genArrayAddr(p: PProc, n: PNode, r: var TCompRes) =
   var typ = skipTypes(m.sons[0].typ, abstractPtrs)
   if typ.kind == tyArray: first = firstOrd(typ.sons[0])
   else: first = 0
-  if optBoundsCheck in p.options and not isConstExpr(m.sons[1]):
+  if optBoundsCheck in p.options:
     useMagic(p, "chckIndx")
     if p.target == targetPHP:
       if typ.kind != tyString:
-        r.res = "chckIndx($1, $2, count($3))-$2" % [b.res, rope(first), a.res]
+        r.res = "chckIndx($1, $2, count($3)-1)-$2" % [b.res, rope(first), a.res]
       else:
         r.res = "chckIndx($1, $2, strlen($3))-$2" % [b.res, rope(first), a.res]
     else:
-      r.res = "chckIndx($1, $2, $3.length)-$2" % [b.res, rope(first), a.res]
+      r.res = "chckIndx($1, $2, $3.length-1)-$2" % [b.res, rope(first), a.res]
   elif first != 0:
     r.res = "($1)-$2" % [b.res, rope(first)]
   else: