Skip to content

Commit

Permalink
Merge ed4cb8a into 1d53232
Browse files Browse the repository at this point in the history
  • Loading branch information
mbauman authored May 11, 2018
2 parents 1d53232 + ed4cb8a commit 3290a43
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ end
## Iteration ##
start(A::Array) = 1
next(a::Array,i) = (@_propagate_inbounds_meta; (a[i],i+1))
done(a::Array,i) = (@_inline_meta; i == length(a)+1)
done(a::Array,i) = (@_inline_meta; i >= length(a)+1)

## Indexing: getindex ##

Expand Down
19 changes: 19 additions & 0 deletions test/arrayops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2424,6 +2424,25 @@ end
@inferred hash([1,2,3])
end

function f27079()
X = rand(5)
for x in X
resize!(X, 0)
end
length(X)
end
function g27079(X)
r = 0
@inbounds for x in X
r += x
end
r
end
@testset "iteration over resized vector" begin
@test f27079() == 0
@test occursin("vector.body", sprint(code_llvm, g27079, Tuple{Vector{Int}}))
end

@testset "indices-related shape promotion errors" begin
@test_throws DimensionMismatch Base.promote_shape((2,), (3,))
@test_throws DimensionMismatch Base.promote_shape((2, 3), (2, 4))
Expand Down

0 comments on commit 3290a43

Please sign in to comment.