This is not a bug. The problem is that col is not constant in example (but it is in example2), so it must be boxed because col must have the same value both in ss and in example (see the col@_4::Core.Box line in the output of @code_warntype example()).
You can solve this problem using a let block as described in the documentation:
function example()
col = 2
ss = let col = col
(col for _ in 1:5)
end
col += 3
return col, ss
end