Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #29266, better error message for deprecated scalar-fill indexed assignment #31085

Merged
merged 4 commits into from
Jun 25, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions base/indices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ function setindex_shape_check(X::AbstractArray{<:Any,2}, i::Integer, j::Integer)
end
end

setindex_shape_check(::Any...) =
throw(ArgumentError("Scalar assignment to a vector is not supported: maybe you wanted to use `.=`?"))
dourouc05 marked this conversation as resolved.
Show resolved Hide resolved

# convert to a supported index type (array or Int)
"""
to_index(A, i)
Expand Down
9 changes: 9 additions & 0 deletions test/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,15 @@ let n = 1
@test ceil.(Int, 1 ./ (1,)) == (1,)
end

# Issue #29266
@testset "deprecated scalar-fill .=" begin
a = fill(1, 10)
@test_throws ArgumentError a[1:5] = 0

x = randn(10)
@test_throws ArgumentError x[x .> 0.0] = 0.0
end


# lots of splatting!
let x = [[1, 4], [2, 5], [3, 6]]
Expand Down