Skip to content

Commit

Permalink
Make at-view(s) match lowering transform (#25958)
Browse files Browse the repository at this point in the history
I missed this change in #25763.
  • Loading branch information
mbauman authored and JeffBezanson committed Feb 9, 2018
1 parent 27c7790 commit f488f33
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions base/subarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ function replace_ref_end_!(ex, withex)
n = 1
J = lastindex(ex.args)
for j = 2:J
exj, used = replace_ref_end_!(ex.args[j],:($size($S,$n)))
exj, used = replace_ref_end_!(ex.args[j],:($lastindex($S,$n)))
used_S |= used
ex.args[j] = exj
if isa(exj,Expr) && exj.head == :...
Expand Down Expand Up @@ -499,7 +499,7 @@ end
# _views implements the transformation for the @views macro.
# @views calls esc(_views(...)) to work around #20241,
# so any function calls we insert (to maybeview, or to
# size and lastindex in replace_ref_end!) must be interpolated
# lastindex in replace_ref_end!) must be interpolated
# as values rather than as symbols to ensure that they are called
# from Base rather than from the caller's scope.
_views(x) = x
Expand Down
17 changes: 17 additions & 0 deletions test/arrayops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2324,3 +2324,20 @@ end
inds_b = Base.Indices{1}([1:3])
@test Base.promote_shape(inds_a, inds_b) == Base.promote_shape(inds_b, inds_a)
end

struct T25958
end
Base.lastindex(::T25958, args...) = (:lastindex, args...)
Base.getindex(::T25958, args...) = args
Base.view(::T25958, args...) = args
@testset "ensure @view and @views matches lowering" begin
t = T25958()
@test t[end] == @view(t[end]) == @views t[end]
@test t[1,end] == @view(t[1,end]) == @views t[1,end]
@test t[end,1] == @view(t[end,1]) == @views t[end,1]
@test t[end,end] == @view(t[end,end]) == @views t[end,end]
@test t[1,end,end] == @view(t[1,end,end]) == @views t[1,end,end]
@test t[end,1,end] == @view(t[end,1,end]) == @views t[end,1,end]
@test t[end,end,1] == @view(t[end,end,1]) == @views t[end,end,1]
@test t[end,end,end] == @view(t[end,end,end]) == @views t[end,end,end]
end

2 comments on commit f488f33

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

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

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

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

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

Please sign in to comment.