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

Test and fix non-int-length bug in view(::Memory, ::Union{UnitRange, Base.OneTo}) #53991

Merged
merged 3 commits into from
Apr 8, 2024
Merged
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/genericmemory.jl
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ end
isempty(inds) && return T[] # needed to allow view(Memory{T}(undef, 0), 2:1)
@boundscheck checkbounds(m, inds)
ref = MemoryRef(m, first(inds)) # @inbounds would be safe here but does not help performance.
dims = (length(inds),)
dims = (Int(length(inds)),)
$(Expr(:new, :(Array{T, 1}), :ref, :dims))
end
end
3 changes: 3 additions & 0 deletions test/arrayops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3205,6 +3205,9 @@ end
@test @inferred(view(mem, -5:-7))::Vector{Int} == []
@test @inferred(reshape(mem, 5, 2))::Matrix{Int} == reshape(11:20, 5, 2)

# 53990
@test @inferred(view(mem, unsigned(1):10))::Vector{Int} == 11:20

empty_mem = Memory{Module}(undef, 0)
@test_throws BoundsError view(empty_mem, 0:1)
@test_throws BoundsError view(empty_mem, 1:2)
Expand Down
3 changes: 3 additions & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5524,6 +5524,9 @@ let a = Base.StringVector(2^17)
@test sizeof(c) == 0
end

# issue #53990 / https://github.com/JuliaLang/julia/pull/53896#discussion_r1555087951
@test Base.StringVector(UInt64(2)) isa Vector{UInt8}

@test_throws ArgumentError eltype(Bottom)

# issue #16424, re-evaluating type definitions
Expand Down