Bug with Julia 1.0.1

I tried to run the following code in Julia 1.0.1 and it fails and I ran the same code in v0.6.4 and it works and I’ve checked and checked and I think it’s an error with v1.0.1.

last_f = 0
max_lrn = 0
pos_of_max = 0
lrn = 1:100
feature = 1:100

for i in 2:length(feature)
    if feature[i] != last_f
        if lrn[i] > max_lrn
            max_lrn = lrn[i]
            pos_of_max = i
        end
    end
end

gives error

UnderVarError: max_lrn not defined

2 Likes
for i in 2:length(feature)
           global max_lrn
           if feature[i] != last_f

There are good reasons it works this way in 1.x but there are also significant reservations about this behavior. That’s what this issue is about.

3 Likes

Interesting. I tried the same code in v0.7 and it did give a Warning.