diff --git a/base/broadcast.jl b/base/broadcast.jl index 4d5ca6b92fe19..afb9700e6702c 100644 --- a/base/broadcast.jl +++ b/base/broadcast.jl @@ -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, diff --git a/base/views.jl b/base/views.jl index 268000cf7765d..1d99e23818c09 100644 --- a/base/views.jl +++ b/base/views.jl @@ -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) diff --git a/test/broadcast.jl b/test/broadcast.jl index 3e39d14cfb440..b758c8090e189 100644 --- a/test/broadcast.jl +++ b/test/broadcast.jl @@ -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 +