Skip to content

Commit d04bda9

Browse files
authored
Improve inferrability of [region...] (#180)
This fixes the following problem: ```julia julia> docat(v) = [v...] docat (generic function with 1 method) julia> code_typed(docat, (UnitRange{Int},)) 1-element Vector{Any}: CodeInfo( 1 ─ %1 = Core._apply_iterate(Base.iterate, Base.vect, v)::Vector{_A} where _A └── return %1 ) => Vector{_A} where _A julia> code_typed(docat, (Vector{Int},)) 1-element Vector{Any}: CodeInfo( 1 ─ %1 = Core._apply_iterate(Base.iterate, Base.vect, v)::Union{Vector{Any}, Vector{Int64}} └── return %1 ) => Union{Vector{Any}, Vector{Int64}} ``` Essentially, because `region...` is implemented via the parser, it relies on the call `vect(args...)` and the risk is that `args` might be empty, which causes it to return `Vector{Any}`.
1 parent 59f38c6 commit d04bda9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/fft.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ unsafe_execute!(plan::r2rFFTWPlan{T},
511511
# Compute dims and howmany for FFTW guru planner
512512
function dims_howmany(X::StridedArray, Y::StridedArray,
513513
sz::Array{Int,1}, region)
514-
reg = [region...]
514+
reg = Int[region...]
515515
if length(unique(reg)) < length(reg)
516516
throw(ArgumentError("each dimension can be transformed at most once"))
517517
end
@@ -578,7 +578,7 @@ for (Tr,Tc,fftw,lib) in ((:Float64,:(Complex{Float64}),"fftw",libfftw3),
578578
Y::StridedArray{$Tc,N},
579579
region, flags::Integer, timelimit::Real) where {inplace,N}
580580
R = isa(region, Tuple) ? region : copy(region)
581-
region = circshift([region...],-1) # FFTW halves last dim
581+
region = circshift(Int[region...],-1) # FFTW halves last dim
582582
unsafe_set_timelimit($Tr, timelimit)
583583
dims, howmany = dims_howmany(X, Y, [size(X)...], region)
584584
plan = ccall(($(string(fftw,"_plan_guru64_dft_r2c")),$lib),
@@ -598,7 +598,7 @@ for (Tr,Tc,fftw,lib) in ((:Float64,:(Complex{Float64}),"fftw",libfftw3),
598598
Y::StridedArray{$Tr,N},
599599
region, flags::Integer, timelimit::Real) where {inplace,N}
600600
R = isa(region, Tuple) ? region : copy(region)
601-
region = circshift([region...],-1) # FFTW halves last dim
601+
region = circshift(Int[region...],-1) # FFTW halves last dim
602602
unsafe_set_timelimit($Tr, timelimit)
603603
dims, howmany = dims_howmany(X, Y, [size(Y)...], region)
604604
plan = ccall(($(string(fftw,"_plan_guru64_dft_c2r")),$lib),

0 commit comments

Comments
 (0)