diff options
author | Araq <rumpf_a@web.de> | 2012-10-24 23:26:13 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2012-10-24 23:26:13 +0200 |
commit | 86ed9181570d16406e63754bd409c2b33c73b4a5 (patch) | |
tree | 4adc39231b7a32393a27fd267fbee7be883c6be7 /compiler | |
parent | 7e31134ff63906ad137dbef0515f531b6f7d4a15 (diff) | |
download | Nim-86ed9181570d16406e63754bd409c2b33c73b4a5.tar.gz |
fixes #235
Diffstat (limited to 'compiler')
-rwxr-xr-x | compiler/ccgexprs.nim | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index abdfbd613..5989d94b3 100755 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -684,6 +684,10 @@ proc genArrayElem(p: BProc, e: PNode, d: var TLoc) = else: lineCg(p, cpsStmts, "if ($1 < $2 || $1 > $3) #raiseIndexError();$n", [rdCharLoc(b), first, intLiteral(lastOrd(ty))]) + else: + let idx = getOrdValue(e.sons[1]) + if idx < firstOrd(ty) or idx > lastOrd(ty): + localError(e.info, errIndexOutOfBounds) if d.k == locNone: d.s = a.s putIntoDest(p, d, elemType(skipTypes(ty, abstractVar)), ropef("$1[($2)- $3]", [rdLoc(a), rdCharLoc(b), first])) |