fix global leak of loop variable `i`

The loop variable `i` in List.fromArray was not defined locally as a var, so it's definition is hoisted to the global scope.