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

Indexing and assigning at once #10186

Closed
juliohm opened this issue Feb 13, 2015 · 2 comments
Closed

Indexing and assigning at once #10186

juliohm opened this issue Feb 13, 2015 · 2 comments
Labels
kind:bug Indicates an unexpected problem or unintended behavior

Comments

@juliohm
Copy link
Sponsor Contributor

juliohm commented Feb 13, 2015

The following code shouldn't work?

julia> a=[3,2,1]
3-element Array{Int64,1}:
 3
 2
 1

julia> a[a]=[4:6]
WARNING: [a] concatenation is deprecated; use [a;] instead
 in depwarn at ./deprecated.jl:40
 in oldstyle_vcat_warning at ./abstractarray.jl:26
 in vect at abstractarray.jl:29
ERROR: BoundsError: attempt to access 3-element Array{Int64,1}:
 3
 5
 4
  at index [4]
 in setindex! at array.jl:377
@tkelman
Copy link
Contributor

tkelman commented Feb 13, 2015

Maybe setindex! could do a sanity check that you aren't trying to use the same array for both the indices and the values to write into? a[copy(a)] = [4,5,6] works just fine, but I'd rather either error for setindex!(A, X, inds) when A === inds, or mark this as wontfix if that check would be too expensive.

@JeffBezanson
Copy link
Sponsor Member

At array.jl:382 this was already fixed if A === the RHS, but not for A === inds. I guess we should check that too.

@JeffBezanson JeffBezanson added the kind:bug Indicates an unexpected problem or unintended behavior label Feb 13, 2015
JeffBezanson added a commit that referenced this issue Feb 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

4 participants