From 6154206f0aa9b4dccef5b6ebe40cc8577df6fe56 Mon Sep 17 00:00:00 2001 From: Lilith Orion Hafner Date: Sun, 7 Apr 2024 19:21:33 -0500 Subject: [PATCH 1/3] test and fix non-int-length bug --- base/genericmemory.jl | 2 +- test/arrayops.jl | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/base/genericmemory.jl b/base/genericmemory.jl index a6f002b9c6175..3463be456ea59 100644 --- a/base/genericmemory.jl +++ b/base/genericmemory.jl @@ -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 diff --git a/test/arrayops.jl b/test/arrayops.jl index 65a9ecbd5e2a2..a31d373a65a38 100644 --- a/test/arrayops.jl +++ b/test/arrayops.jl @@ -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) From 34422c7d684f81f9e172e81b09ca28735ec1e8fa Mon Sep 17 00:00:00 2001 From: Lilith Orion Hafner Date: Sun, 7 Apr 2024 19:25:59 -0500 Subject: [PATCH 2/3] add another test --- test/core.jl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/core.jl b/test/core.jl index 173526d3b2128..7a8c7d8c61bae 100644 --- a/test/core.jl +++ b/test/core.jl @@ -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 String + @test_throws ArgumentError eltype(Bottom) # issue #16424, re-evaluating type definitions From a8bd363a197879407db5115ba867b6e2b1a7dcf7 Mon Sep 17 00:00:00 2001 From: Lilith Orion Hafner Date: Sun, 7 Apr 2024 19:26:45 -0500 Subject: [PATCH 3/3] fixup --- test/core.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/core.jl b/test/core.jl index 7a8c7d8c61bae..ed1e1fc6757d2 100644 --- a/test/core.jl +++ b/test/core.jl @@ -5525,7 +5525,7 @@ let a = Base.StringVector(2^17) end # issue #53990 / https://github.com/JuliaLang/julia/pull/53896#discussion_r1555087951 -@test Base.StringVector(UInt64(2)) isa String +@test Base.StringVector(UInt64(2)) isa Vector{UInt8} @test_throws ArgumentError eltype(Bottom)