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

pass kwargs along maybeview and dotview #31732

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion base/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,7 @@ end
# explicit calls to view. (All of this can go away if slices
# are changed to generate views by default.)

Base.@propagate_inbounds dotview(args...) = Base.maybeview(args...)
Base.@propagate_inbounds dotview(args...; kwargs...) = Base.maybeview(args...; kwargs...)

############################################################
# The parser turns @. into a call to the __dot__ macro,
Expand Down
6 changes: 3 additions & 3 deletions base/views.jl
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ end

# maybeview is like getindex, but returns a view for slicing operations
# (while remaining equivalent to getindex for scalar indices and non-array types)
@propagate_inbounds maybeview(A, args...) = getindex(A, args...)
@propagate_inbounds maybeview(A::AbstractArray, args...) = view(A, args...)
@propagate_inbounds maybeview(A::AbstractArray, args::Number...) = getindex(A, args...)
@propagate_inbounds maybeview(A, args...; kwargs...) = getindex(A, args...; kwargs...)
@propagate_inbounds maybeview(A::AbstractArray, args...; kwargs...) = view(A, args...; kwargs...)
@propagate_inbounds maybeview(A::AbstractArray, args::Number...; kwargs...) = getindex(A, args...; kwargs...)
@propagate_inbounds maybeview(A) = getindex(A)
@propagate_inbounds maybeview(A::AbstractArray) = getindex(A)

Expand Down
6 changes: 6 additions & 0 deletions test/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -818,3 +818,9 @@ let a = rand(5), b = rand(5), c = copy(a)
view(identity(a), 1:3) .+= view(b, 1:3)
@test a == [(c+b)[1:3]; c[4:5]]
end

# issue #31729
struct DummyNamedDimsArray <: AbstractArray{Int,2} end
Base.getindex(::DummyNamedDimsArray; x) = x
@test Base.dotview(DummyNamedsDimArray(); x=5) == 5