julia> using LinearAlgebra, Cthulhu, JET
julia> D = Diagonal(rand(2));
julia> @descend setindex!(D, 2, 1, 2) # Cthulhu
setindex!(D::Diagonal, v, i::Int64, j::Int64) @ LinearAlgebra ~/.julia/juliaup/julia-1.11.0-alpha2+0.x64.linux.gnu/share/julia/stdlib/v1.11/LinearAlgebra/src/diagonal.jl:188
188 function setindex!(D::Diagonal{Float64, Vector{Float64}}::Diagonal, v::Int64, i::Int64::Int, j::Int64::Int)::Int64
189 @boundscheck checkbounds(D::Diagonal{Float64, Vector{Float64}}, i::Int64, j::Int64)
190 if (i::Int64 == j::Int64)::Bool
191 @inbounds D::Diagonal{Float64, Vector{Float64}}.diag::Vector{Float64}[i::Int64] = v::Int64
192 elseif !(iszero(v::Int64)::Bool)::Bool
193 throw(ArgumentError("cannot set off-diagonal entry ($i::Int64, $j::Int64) to a nonzero value ($v::Int64)"::Any)::Any)
194 end
195 return v::Int64
196 end
Select a call to descend into or β© to ascend. [q]uit. [b]ookmark.
Toggles: [w]arn, [h]ide type-stable statements, [t]ype annotations, [s]yntax highlight for Source/LLVM/Native, [j]ump to source always.
Show: [S]ource code, [A]ST, [T]yped code, [L]LVM IR, [N]ative code
Actions: [E]dit source code, [R]evise and redisplay
β’ %5 = checkbounds(::Diagonal{Float64, Vector{Float64}},::Int64,::Int64)::Any
i::Int64 == j::Int64
D::Diagonal{Float64, Vector{Float64}}.diag
%10 = setindex!(::Vector{Float64},::Int64,::Int64)::Any
iszero(v::Int64)
!iszero(v::Int64)::Bool
runtime "cannot set off-diagonal entry ($i::Int64, $j::Int64) to a nonzero value ($v::Int64)"
runtime ArgumentError("cannot set off-diagonal entry ($i::Int64, $j::Int64) to a nonzero value ($v::Int64)"::Any)
β©
julia> @report_opt setindex!(D, 2, 1, 2) # JET
No errors detected
julia> VERSION
v"1.11.0-alpha2"
Cthulhu marks the string interpolation in the ArgumentError
message as a runtime dispatch, but JET doesnβt report this (although it does report similar calls elsewhere).