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

Add some aliasing warnings to docstrings for mutating functions in Base #50824

Merged
merged 17 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3340,7 +3340,7 @@ end
Like [`map`](@ref), but stores the result in `destination` rather than a new
collection. `destination` must be at least as large as the smallest collection.

Note that since the `map!` function is intended to operate without making any allocations, the target `destination` must not share memory with any of the sources in `collection...`.
Note that the order in which the `collection`s are iterated is undefined. This means you should be careful whenever the target `destination` shares memory with any of the `collection`s, because you may get an incorrect result.
gdalle marked this conversation as resolved.
Show resolved Hide resolved

See also: [`map`](@ref), [`foreach`](@ref), [`zip`](@ref), [`copyto!`](@ref).

Expand Down
8 changes: 4 additions & 4 deletions base/accumulate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ end

Cumulative sum of `A` along the dimension `dims`, storing the result in `B`. See also [`cumsum`](@ref).

Note that since the `cumsum!` function is intended to operate without making any allocations, the target `B` must not share memory with the source `A`.
Note that the target `B` must not share memory with the source `A`, otherwise the behavior is undefined.
gdalle marked this conversation as resolved.
Show resolved Hide resolved
"""
cumsum!(B::AbstractArray{T}, A; dims::Integer) where {T} =
accumulate!(add_sum, B, A, dims=dims)
Expand Down Expand Up @@ -153,7 +153,7 @@ cumsum(itr) = accumulate(add_sum, itr)
Cumulative product of `A` along the dimension `dims`, storing the result in `B`.
See also [`cumprod`](@ref).

Note that since the `cumprod!` function is intended to operate without making any allocations, the target `B` must not share memory with the source `A`.
Note that the target `B` must not share memory with the source `A`, otherwise the behavior is undefined.
"""
cumprod!(B::AbstractArray{T}, A; dims::Integer) where {T} =
accumulate!(mul_prod, B, A, dims=dims)
Expand All @@ -164,7 +164,7 @@ cumprod!(B::AbstractArray{T}, A; dims::Integer) where {T} =
Cumulative product of a vector `x`, storing the result in `y`.
See also [`cumprod`](@ref).

Note that since the `cumprod!` function is intended to operate without making any allocations, the target `y` must not share memory with the source `x`.
Note that the target `y` must not share memory with the source `x`, otherwise the behavior is undefined.
"""
cumprod!(y::AbstractVector, x::AbstractVector) = cumprod!(y, x, dims=1)

Expand Down Expand Up @@ -307,7 +307,7 @@ Cumulative operation `op` on `A` along the dimension `dims`, storing the result
Providing `dims` is optional for vectors. If the keyword argument `init` is given, its
value is used to instantiate the accumulation.

Note that since the `accumulate!` function is intended to operate without making any allocations, the target `B` must not share memory with the source `A`.
Note that the target `B` must not share memory with the source `A`, otherwise the behavior is undefined.

See also [`accumulate`](@ref), [`cumsum!`](@ref), [`cumprod!`](@ref).

Expand Down
10 changes: 5 additions & 5 deletions base/reducedim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ _count(f, A::AbstractArrayOrBroadcasted, dims, init) = mapreduce(_bool(f), add_s
Count the number of elements in `A` for which `f` returns `true` over the
singleton dimensions of `r`, writing the result into `r` in-place.

Note that since the `count!` function is intended to operate without making any allocations, the target `r` must not share memory with the source `A`.
Note that the target `r` must not share memory with the source `A`, otherwise the behavior is undefined.

!!! compat "Julia 1.5"
inplace `count!` was added in Julia 1.5.
Expand Down Expand Up @@ -528,7 +528,7 @@ sum(f, A::AbstractArray; dims)

Sum elements of `A` over the singleton dimensions of `r`, and write results to `r`.

Note that since the `sum!` function is intended to operate without making any allocations, the target `r` must not share memory with the source `A`.
Note that the target `r` must not share memory with the source `A`, otherwise the behavior is undefined.

# Examples
```jldoctest
Expand Down Expand Up @@ -603,7 +603,7 @@ prod(f, A::AbstractArray; dims)

Multiply elements of `A` over the singleton dimensions of `r`, and write results to `r`.

Note that since the `prod!` function is intended to operate without making any allocations, the target `r` must not share memory with the source `A`.
Note that the target `r` must not share memory with the source `A`, otherwise the behavior is undefined.

# Examples
```jldoctest
Expand Down Expand Up @@ -899,7 +899,7 @@ all(::Function, ::AbstractArray; dims)

Test whether all values in `A` along the singleton dimensions of `r` are `true`, and write results to `r`.

Note that since the `all!` function is intended to operate without making any allocations, the target `r` must not share memory with the source `A`.
Note that the target `r` must not share memory with the source `A`, otherwise the behavior is undefined.

# Examples
```jldoctest
Expand Down Expand Up @@ -974,7 +974,7 @@ any(::Function, ::AbstractArray; dims)
Test whether any values in `A` along the singleton dimensions of `r` are `true`, and write
results to `r`.

Note that since the `any!` function is intended to operate without making any allocations, the target `r` must not share memory with the source `A`.
Note that the target `r` must not share memory with the source `A`, otherwise the behavior is undefined.

# Examples
```jldoctest
Expand Down
2 changes: 1 addition & 1 deletion stdlib/LinearAlgebra/src/matmul.jl
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ end

Calculates the matrix-matrix or matrix-vector product `AB` and stores the result in `Y`, overwriting the existing value of `Y`.

Note that `Y` must not share memory with either `A` or `B`.
Note that the target `Y` must not share memory with either `A` or `B`, otherwise the behavior is undefined.

# Examples
```jldoctest
Expand Down