# Circcopy! does not infer for 3D arrays

**URL:** <https://discourse.julialang.org/t/circcopy-does-not-infer-for-3d-arrays/36401>\
**Category:** General Usage\
**Created:** [March 23, 2020, 4:17pm UTC](https://discourse.julialang.org/t/circcopy-does-not-infer-for-3d-arrays/36401 "2020-03-23T16:17:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![raminammour](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raminammour/32/13572_2.png) [@raminammour](https://discourse.julialang.org/u/raminammour)\
**Post date:** [March 23, 2020, 4:17pm UTC](https://discourse.julialang.org/t/circcopy-does-not-infer-for-3d-arrays/36401/1 "2020-03-23T16:17:20Z")

</div>

Found while tracking down a type instability in FFTW ([FFT(W) does not infer](https://discourse.julialang.org/t/fft-w-does-not-infer/36393)). Is this a bug? Any ideas?

```julia
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.
