<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="julia&gt; using OffsetArrays, LinearAlgebra

julia&gt; convert(OffsetArray{ComplexF64,2, Diagonal{ComplexF64,Vector{ComplexF64}}}, OffsetArray(zeros(ComplexF64,3,3), 0,0))
ERROR: MethodError: Cannot `convert` an object of type 
  OffsetArray{Complex{Float64{}},2,Matrix{ComplexF64}} to an object of type 
  OffsetArray{Complex{Float64{}},2,Diagonal{ComplexF64, Vector{ComplexF64}}}
Closest candidates are:
  convert(::Type{T}, ::Factorization) where T&lt;:AbstractArray at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.7/LinearAlgebra/src/factorization.jl:58
  convert(::Type{T}, ::T) where T&lt;:AbstractArray at abstractarray.jl:16
  convert(::Type{T}, ::T) where T at essentials.jl:228
  ...
Stacktrace:
 [1] top-level scope
   @ REPL[16]:1

julia&gt; VERSION
v&quot;1.7.0-DEV.1025&quot;"><pre class="notranslate">julia<span class="pl-k">&gt;</span> <span class="pl-k">using</span> OffsetArrays, LinearAlgebra

julia<span class="pl-k">&gt;</span> <span class="pl-c1">convert</span>(OffsetArray{ComplexF64,<span class="pl-c1">2</span>, Diagonal{ComplexF64,Vector{ComplexF64}}}, <span class="pl-c1">OffsetArray</span>(<span class="pl-c1">zeros</span>(ComplexF64,<span class="pl-c1">3</span>,<span class="pl-c1">3</span>), <span class="pl-c1">0</span>,<span class="pl-c1">0</span>))
ERROR<span class="pl-k">:</span> MethodError<span class="pl-k">:</span> Cannot <span class="pl-s"><span class="pl-pds">`</span>convert<span class="pl-pds">`</span></span> an object of type 
  OffsetArray{Complex{Float64{}},<span class="pl-c1">2</span>,Matrix{ComplexF64}} to an object of type 
  OffsetArray{Complex{Float64{}},<span class="pl-c1">2</span>,Diagonal{ComplexF64, Vector{ComplexF64}}}
Closest candidates are<span class="pl-k">:</span>
  <span class="pl-c1">convert</span>(<span class="pl-k">::</span><span class="pl-c1">Type{T}</span>, <span class="pl-k">::</span><span class="pl-c1">Factorization</span>) <span class="pl-k">where</span> T<span class="pl-k">&lt;:</span><span class="pl-c1">AbstractArray</span> at <span class="pl-k">/</span>buildworker<span class="pl-k">/</span>worker<span class="pl-k">/</span>package_linux64<span class="pl-k">/</span>build<span class="pl-k">/</span>usr<span class="pl-k">/</span>share<span class="pl-k">/</span>julia<span class="pl-k">/</span>stdlib<span class="pl-k">/</span>v1.<span class="pl-c1">7</span><span class="pl-k">/</span>LinearAlgebra<span class="pl-k">/</span>src<span class="pl-k">/</span>factorization<span class="pl-k">.</span>jl<span class="pl-k">:</span><span class="pl-c1">58</span>
  <span class="pl-c1">convert</span>(<span class="pl-k">::</span><span class="pl-c1">Type{T}</span>, <span class="pl-k">::</span><span class="pl-c1">T</span>) <span class="pl-k">where</span> T<span class="pl-k">&lt;:</span><span class="pl-c1">AbstractArray</span> at abstractarray<span class="pl-k">.</span>jl<span class="pl-k">:</span><span class="pl-c1">16</span>
  <span class="pl-c1">convert</span>(<span class="pl-k">::</span><span class="pl-c1">Type{T}</span>, <span class="pl-k">::</span><span class="pl-c1">T</span>) <span class="pl-k">where</span> T at essentials<span class="pl-k">.</span>jl<span class="pl-k">:</span><span class="pl-c1">228</span>
  <span class="pl-k">...</span>
Stacktrace<span class="pl-k">:</span>
 [<span class="pl-c1">1</span>] top<span class="pl-k">-</span>level scope
   @ REPL[<span class="pl-c1">16</span>]<span class="pl-k">:</span><span class="pl-c1">1</span>

julia<span class="pl-k">&gt;</span> <span class="pl-c1">VERSION</span>
<span class="pl-s"><span class="pl-pds"><span class="pl-c1">v</span>"</span>1.7.0-DEV.1025<span class="pl-pds">"</span></span></pre></div>
<p dir="auto">The eltype in the error message is displayed as <code class="notranslate">Complex{Float64{}}</code> instead of <code class="notranslate">Complex{Float64}</code>. This only happens for some combinations of types.</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="julia&gt; typealias SelfDict{T} Dict{T,T}
Dict{T,T}

julia&gt; isself(d::Dict) = false
# methods for generic function isself
isself(d::Dict{K,V}) at none:1

julia&gt; isself(d::SelfDict) = true
# methods for generic function isself
isself(d::Dict{T,T}) at none:1

julia&gt; isself([1=&gt;2])
true

julia&gt; isself([1=&gt;&quot;foo&quot;])
true"><pre class="notranslate">julia<span class="pl-k">&gt;</span> typealias SelfDict{T} Dict{T,T}
Dict{T,T}

julia<span class="pl-k">&gt;</span> <span class="pl-en">isself</span>(d<span class="pl-k">::</span><span class="pl-c1">Dict</span>) <span class="pl-k">=</span> <span class="pl-c1">false</span>
<span class="pl-c"><span class="pl-c">#</span> methods for generic function isself</span>
<span class="pl-c1">isself</span>(d<span class="pl-k">::</span><span class="pl-c1">Dict{K,V}</span>) at none<span class="pl-k">:</span><span class="pl-c1">1</span>

julia<span class="pl-k">&gt;</span> <span class="pl-en">isself</span>(d<span class="pl-k">::</span><span class="pl-c1">SelfDict</span>) <span class="pl-k">=</span> <span class="pl-c1">true</span>
<span class="pl-c"><span class="pl-c">#</span> methods for generic function isself</span>
<span class="pl-c1">isself</span>(d<span class="pl-k">::</span><span class="pl-c1">Dict{T,T}</span>) at none<span class="pl-k">:</span><span class="pl-c1">1</span>

julia<span class="pl-k">&gt;</span> <span class="pl-c1">isself</span>([<span class="pl-c1">1</span><span class="pl-k">=&gt;</span><span class="pl-c1">2</span>])
<span class="pl-c1">true</span>

julia<span class="pl-k">&gt;</span> <span class="pl-c1">isself</span>([<span class="pl-c1">1</span><span class="pl-k">=&gt;</span><span class="pl-s"><span class="pl-pds">"</span>foo<span class="pl-pds">"</span></span>])
<span class="pl-c1">true</span></pre></div>