Fix #6262

Use an Int for the accumulation variable when iterating over integer
types smaller than Int, and the type of the range when iterating over
types larger than Int
Remove unnecessary eval
Merge pull request #6266 from JuliaLang/sjk/ranges

Fix #6262