JuliaLang/julia — Issue #292: array iterator generating bad code
Author: vtjnash
Created: 2011-12-08 07:41:11+00:00
State: open
Labels: bugs

julia> function a()
x=[1,2,3]
function b()
for i=x
print(i)
end
end
b()
end

julia> a()
in b: #1237 not defined
in b, prompt:4
in a, prompt:8
in run_repl, /Users/jameson/Desktop/18.337/julia/j/client.j:22
in _start, /Users/jameson/Desktop/18.337/julia/j/client.j:128

julia> function a()
x=[1,2,3]
function b()
for i=1:length(x)
print(x[i])
end
end
b()
end

julia> a()
123

julia> function a()
x=[1,2,3]
function b()
for i=1:length(x)
print(x[i])
end
end
for i=x
print(x)
end
println()
b()
end

julia> a()
[1, 2, 3][1, 2, 3][1, 2, 3]
123
julia> for i = [1,2,3]
print(i)
end
123
julia> x=[1,2,3]
[1, 2, 3]

julia> for i = x
print(i)
end
123
julia>