# JET is unhappy with broadcast assigning a matrix to a submatrix, rooted in \`abstractarray.jl\`

**URL:** <https://discourse.julialang.org/t/jet-is-unhappy-with-broadcast-assigning-a-matrix-to-a-submatrix-rooted-in-abstractarray-jl/83750>\
**Category:** General Usage\
**Tags:** inference, jet\
**Created:** [July 4, 2022, 4:34pm UTC](https://discourse.julialang.org/t/jet-is-unhappy-with-broadcast-assigning-a-matrix-to-a-submatrix-rooted-in-abstractarray-jl/83750 "2022-07-04T16:34:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Krastanov](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/krastanov/32/6817_2.png) [@Krastanov](https://discourse.julialang.org/u/Krastanov)\
**Post date:** [July 4, 2022, 4:34pm UTC](https://discourse.julialang.org/t/jet-is-unhappy-with-broadcast-assigning-a-matrix-to-a-submatrix-rooted-in-abstractarray-jl/83750/1 "2022-07-04T16:34:13Z")

</div>

This seems like a pretty innocent piece of code but JET reports a possible issue.

```julia
julia> function f1(n) # Vectors work fine
           m = zeros(2n)
           sub = zeros(n)
           m[n+1:2n] .= sub
           m
       end
       @report_call f1(10)
No errors detected

julia> function f2(n) # Matrices have issues
           m = zeros(2n, 2n)
           sub = zeros(n, n) # this needs to be a matrix to trigger the issue
           m[n+1:2n, n+1:2n] .= sub
           m
       end
       @report_call f2(10)
═════ 2 possible errors found ═════
┌ @ REPL[31]:4 Base.materialize!(Base.dotview(m, n + 1 : 2 * n, n + 1 : 2 * n), Base.broadcasted(identity, sub))
│┌ @ broadcast.jl:881 Base.Broadcast.materialize!(Base.Broadcast.combine_styles(dest, bc), dest, bc)
││┌ @ broadcast.jl:884 Base.Broadcast.copyto!(dest, Base.Broadcast.instantiate(Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{2}}(bc.f, bc.args, Base.Broadcast.axes(dest))))
│││┌ @ broadcast.jl:926 Base.Broadcast.copyto!(dest, Base.Broadcast.convert(Base.Broadcast.Broadcasted{Nothing}, bc))
││││┌ @ broadcast.jl:967 Base.Broadcast.copyto!(dest, A)
│││││┌ @ abstractarray.jl:1039 Base.copyto_unaliased!(IndexStyle(dest), dest, IndexStyle(src′), src′)
││││││┌ @ abstractarray.jl:1079 Base.indexed_iterate(ret, 1)
│││││││┌ @ tuple.jl:91 x = iterate(I)
││││││││ no matching method found `iterate(::Nothing)`: x = iterate(I::Nothing)::Union{}
│││││││└───────────────
││││││┌ @ abstractarray.jl:1079 Base.indexed_iterate(ret, 2, _26)
│││││││┌ @ tuple.jl:96 x = iterate(I, state)
││││││││ no matching method found `iterate(::Nothing, ::Int64)`: x = iterate(I::Nothing, state::Int64)::Union{}
│││││││└───────────────

```

Here are the lines that JET is complaining about: [julia/abstractarray.jl at 05eb1530bbfe2db0dd6c9a13ea065f17cb9730cf · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/blob/05eb1530bbfe2db0dd6c9a13ea065f17cb9730cf/base/abstractarray.jl#L1077-L1082=)

I currently do not understand well why JET is unhappy with these lines, so any insight would be welcomed. Is this a legitimate issue in Base or a false positive? What would be the best way to eliminate the issue?

This is on today’s Julia nightly and today’s JET master.

```julia
julia> versioninfo()
Julia Version 1.9.0-DEV.875
Commit 05eb1530bbf (2022-07-01 22:42 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 16 × AMD Ryzen 7 1700 Eight-Core Processor
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.5 (ORCJIT, znver1)
  Threads: 8 on 16 virtual cores
Environment:
  JULIA_EDITOR = code
  JULIA_NUM_THREADS = 8

(clifford) pkg> st JET
Status `~/Documents/ScratchSpace/clifford/Project.toml`
  [c3a54625] JET v0.5.16 `https://github.com/aviatesk/JET.jl.git#master`

```

posted on the JET issue tracker: [Detected issues when assigning a matrix to a submatrix, rooted in Base `abstractarray.jl` · Issue #374 · aviatesk/JET.jl · GitHub](https://github.com/aviatesk/JET.jl/issues/374)
