Found while tracking down a type instability in FFTW (FFT(W) does not infer). Is this a bug? Any ideas?
u=rand(3,2,4)
@code_warntype circcopy!(copy(u),u)
Variables
#self#::Core.Compiler.Const(circcopy!, false)
dest::Array{Float64,3}
src::Array{Float64,3}
#419::Base.var"#419#421"
#420::Base.var"#420#422"
indssrc::Tuple{Base.OneTo{Int64},Base.OneTo{Int64},Base.OneTo{Int64}}
indsdest::Tuple{Base.OneTo{Int64},Base.OneTo{Int64},Base.OneTo{Int64}}
szsrc::Tuple{Int64,Int64,Int64}
szdest::Tuple{Int64,Int64,Int64}
shift::Tuple{Int64,Int64,Int64}
Body::Any
1 ─ Core.NewvarNode(:(#419))
│ Core.NewvarNode(:(#420))
│ Core.NewvarNode(:(indssrc))
│ Core.NewvarNode(:(indsdest))
│ Core.NewvarNode(:(szsrc))
│ Core.NewvarNode(:(szdest))
│ Core.NewvarNode(:(shift))
│ %8 = (dest === src)::Bool
└── goto #3 if not %8
2 ─ %10 = Base.ArgumentError("dest and src must be separate arrays")::ArgumentError
│ Base.throw(%10)
└── Core.Compiler.Const(:(goto %14), false)
3 ┄ false
│ %14 = Base.axes(src)::Tuple{Base.OneTo{Int64},Base.OneTo{Int64},Base.OneTo{Int64}}
│ %15 = Base.axes(dest)::Tuple{Base.OneTo{Int64},Base.OneTo{Int64},Base.OneTo{Int64}}
│ (indssrc = %14)
│ (indsdest = %15)
│ %18 = Base.map(Base.length, indssrc)::Tuple{Int64,Int64,Int64}
│ (szsrc = %18)
│ %20 = Base.map(Base.length, indsdest)::Tuple{Int64,Int64,Int64}
│ (szdest = %20)
│ %22 = (%18 != %20)::Bool
└── goto #5 if not %22
4 ─ %24 = Base.string("src and dest must have the same sizes (got ", szsrc, " and ", szdest, ")")::String
│ %25 = Base.DimensionMismatch(%24)::DimensionMismatch
└── Base.throw(%25)
5 ┄ (#419 = %new(Base.:(var"#419#421")))
│ %28 = #419::Core.Compiler.Const(Base.var"#419#421"(), false)
│ %29 = indssrc::Tuple{Base.OneTo{Int64},Base.OneTo{Int64},Base.OneTo{Int64}}
│ (shift = Base.map(%28, %29, indsdest))
│ (#420 = %new(Base.:(var"#420#422")))
│ %32 = #420::Core.Compiler.Const(Base.var"#420#422"(), false)
│ %33 = Base.all(%32, shift::Core.Compiler.Const((0, 0, 0), false))::Bool
└── goto #8 if not %33
6 ─ %35 = Base.copyto!(dest, src)::Array{Float64,3}
└── return %35
7 ─ Core.Compiler.Const(:(goto %39), false)
8 ┄ false
│ %39 = ()::Core.Compiler.Const((), false)
│ %40 = indsdest::Tuple{Base.OneTo{Int64},Base.OneTo{Int64},Base.OneTo{Int64}}
│ %41 = ()::Core.Compiler.Const((), false)
│ %42 = Base._circcopy!(dest, %39, %40, src, %41, indssrc)::Any
└── return %42
p.s.: it works for 2D arrays.