Here is the relevant part of debugging. The > is the call that ultimately throws the error.
In \(A, B) at /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/LinearAlgebra/src/triangular.jl:1656
1656 @eval function \(A::Union{UpperTriangular,LowerTriangular}, B::$mat)
1657 require_one_based_indexing(B)
1658 TAB = typeof((zero(eltype(A))*zero(eltype(B)) + zero(eltype(A))*zero(eltype(B)))/one(eltype(A)))
1659 BB = similar(B, TAB, size(B))
>1660 copyto!(BB, B)
1661 ldiv!(convert(AbstractArray{TAB}, A), BB)
1662 end
About to run: <(copyto!)([-0.6457306721039766, 2.308264642e-314], Real[-0.6457306721039766, Dual{Float64}(-1.5900782...>
8|debug> fr
[8] \(A, B) at /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/LinearAlgebra/src/triangular.jl:1656
| A::LinearAlgebra.LowerTriangular{Float64, LinearAlgebra.Adjoint{Float64, Matrix{Float64}}} = [1.0 0.0; 0.5 0.8660254037844386]
| B::Vector{Real} = Real[-0.6457306721039766, Dual{Float64}(-1.5900782022924036,-0.481991677966545)]
| BB::Vector{Float64} = [-0.6457306721039766, 2.308264642e-314]
| TAB::DataType = Float64
The problem is that B is only a vector of Real and not Dual and conversion to TAB = Float64 is attempted.
I could ‘cure’ it manually by doing
julia> T = ForwardDiff.Tag(getllh, Float64)
ForwardDiff.Tag{typeof(getllh), Float64}()
julia> ad = ForwardDiff.Dual{T}(1.0,0.0)
Dual{ForwardDiff.Tag{typeof(getllh), Float64}()}(1.0,0.0)
julia> bd = ForwardDiff.Dual{T}(1.0,1.0)
Dual{ForwardDiff.Tag{typeof(getllh), Float64}()}(1.0,1.0)
julia> getllh(0.5,ad,bd,draws)
Dual{ForwardDiff.Tag{typeof(getllh), Float64}()}(-1850.7331612741796,-56.25528540379574)
Edit: Or by taking a gradient
julia> ForwardDiff.gradient(x -> getllh(0.5,x[1],x[2],draws),[1.0,1.0]) # Errors.
2-element Vector{Float64}:
54.86694187385668
-56.25528540379574
I guess the two entries in B are the parameters of the two exponential distributions. At some point they get bunched together and I would suggest you try and promote them to a common concrete type then.