-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
12 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -920,7 +920,7 @@ proc genArrayElem(p: BProc, n, x, y: PNode, d: var TLoc) = | |
if optBoundsCheck in p.options and ty.kind != tyUncheckedArray: | ||
if not isConstExpr(y): | ||
# semantic pass has already checked for const index expressions | ||
if firstOrd(p.config, ty) == 0: | ||
if firstOrd(p.config, ty) == 0 and lastOrd(p.config, ty) >= 0: | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Araq
Author
Member
|
||
if (firstOrd(p.config, b.t) < firstOrd(p.config, ty)) or (lastOrd(p.config, b.t) > lastOrd(p.config, ty)): | ||
linefmt(p, cpsStmts, "if ((NU)($1) > (NU)($2)){ #raiseIndexError2($1, $2); $3}$n", | ||
[rdCharLoc(b), intLiteral(lastOrd(p.config, ty)), raiseInstr(p)]) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Araq
Does this fix works for JavaScript too?.
Can the compiler emit a warning for an array of static size
0
?,I mean whats an array of size
0
useful for?.