Skip to content

Commit

Permalink
fix #10186, a[a] = x
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Feb 13, 2015
1 parent 478dcb4 commit f8973cb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,9 @@ function setindex!{T<:Real}(A::Array, X::AbstractArray, I::AbstractVector{T})
count = 1
if is(X,A)
X = copy(X)
is(I,A) && (I = X)
elseif is(I,A)
I = copy(I)
end
for i in I
A[i] = X[count]
Expand Down
3 changes: 3 additions & 0 deletions test/arrayops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,9 @@ a = [1,3,5]
b = [3,1,2]
a[b] = a
@test a == [3,5,1]
a = [3,2,1]
a[a] = [4,5,6]
@test a == [6,5,4]

# lexicographic comparison
@test lexcmp([1.0], [1]) == 0
Expand Down

9 comments on commit f8973cb

@StefanKarpinski
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ivarne
Copy link
Member

@ivarne ivarne commented on f8973cb Feb 14, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that seemed relevant. I labeled the issue so that we'll see this again.

@tkelman
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably harmless enough to squeeze in before 0.3.6? hard to see how this could cause any trouble

@staticfloat
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, let's just backport this.

@staticfloat
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cherry-picked in 723280c

@timholy
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this commit made the loop type-unstable (I either has typeof(X) or its original type), which really kills performance.

@timholy
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can fix later, if no one beats me to it, but I have other obligations first.

@mbauman
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have the fix in #10525, too. I should have just pushed it to master right away.

@mbauman
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.