Skip to content

Commit

Permalink
fix closure iter state table init type [backport] (nim-lang#20717)
Browse files Browse the repository at this point in the history
fix closure iter state table init type

It is a well-known fact that using closed intervals for ranges is
logically, objectively and eternally wrong, as evidenced by this
off-by-one.
  • Loading branch information
arnetheduck authored and bung87 committed Jul 29, 2023
1 parent 2fbdae8 commit 44d0dc8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/closureiters.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,7 @@ proc newArrayType(g: ModuleGraph; n: int, t: PType; idgen: IdGenerator; owner: P
result = newType(tyArray, nextTypeId(idgen), owner)

let rng = newType(tyRange, nextTypeId(idgen), owner)
rng.n = newTree(nkRange, g.newIntLit(owner.info, 0), g.newIntLit(owner.info, n))
rng.n = newTree(nkRange, g.newIntLit(owner.info, 0), g.newIntLit(owner.info, n - 1))
rng.rawAddSon(t)

result.rawAddSon(rng)
Expand Down

0 comments on commit 44d0dc8

Please sign in to comment.