File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -514,7 +514,17 @@ function BangBang.possible(
514
514
return BangBang. implements (setindex!, C) &&
515
515
promote_type (eltype (C), eltype (T)) <: eltype (C)
516
516
end
517
- # NOTE: Makes it possible to use ranges, etc. for setting a vector.
517
+ # HACK: Makes it possible to use ranges, etc. for setting a vector.
518
+ # For example, without this hack, BangBang.jl will consider
519
+ #
520
+ # x[1:2] = [1, 2]
521
+ #
522
+ # as NOT supported. This results is calling the immutable
523
+ # `BangBang.setindex` instead, which also ends up expanding the
524
+ # type of the containing array (`x` in the above scenario) to
525
+ # have element type `Any`.
526
+ # The below code just, correctly, marks this as possible and
527
+ # thus we hit the mutable `setindex!` instead.
518
528
function BangBang. possible (
519
529
:: typeof (BangBang. _setindex!), :: C , :: T , :: AbstractVector{<:Integer}
520
530
) where {C<: AbstractVector ,T<: AbstractVector }
You can’t perform that action at this time.
0 commit comments