# Unexpectedly long method signature in "Closest candidates" list

**URL:** <https://discourse.julialang.org/t/unexpectedly-long-method-signature-in-closest-candidates-list/32537>\
**Category:** General Usage\
**Tags:** question\
**Created:** [December 21, 2019, 4:48am UTC](https://discourse.julialang.org/t/unexpectedly-long-method-signature-in-closest-candidates-list/32537 "2019-12-21T04:48:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![CameronBieganek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cameronbieganek/32/6915_2.png) [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)\
**Post date:** [December 21, 2019, 4:48am UTC](https://discourse.julialang.org/t/unexpectedly-long-method-signature-in-closest-candidates-list/32537/1 "2019-12-21T04:48:36Z")

</div>

I just came across this frighteningly long method signature in the “Closest candidates” list of methods after a `MethodError`:

```julia
julia> x, y = [1, 2], [3, 4];

julia> x * y
ERROR: MethodError: no method matching *(::Array{Int64,1}, ::Array{Int64,1})
Closest candidates are:
  *(::Any, ::Any, ::Any, ::Any...) at operators.jl:529
  *(::LinearAlgebra.Adjoint{#s627,#s626} where #s626<:Union{DenseArray{T,2}, Base.ReinterpretArray{T,2,S,A} where S where A<:Union{SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray}, Base.ReshapedArray{T,2,A,MI} where MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A<:Union{Base.ReinterpretArray{T,N,S,A} where S where A<:Union{SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray} where N where T, SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray}, SubArray{T,2,A,I,L} where L where I<:Tuple{Vararg{Union{Int64, AbstractRange{Int64}, Base.AbstractCartesianIndex},N} where N} where A<:Union{Base.ReinterpretArray{T,N,S,A} where S where A<:Union{SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray} where N where T, Base.ReshapedArray{T,N,A,MI} where MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A<:Union{Base.ReinterpretArray{T,N,S,A} where S where A<:Union{SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray} where N where T, SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray} where N where T, DenseArray}} where #s627, ::Union{DenseArray{S,1}, Base.ReinterpretArray{S,1,S1,A} where S1 where A<:Union{SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray}, Base.ReshapedArray{S,1,A,MI} where MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A<:Union{Base.ReinterpretArray{T,N,S,A} where S where A<:Union{SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray} where N where T, SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray}, SubArray{S,1,A,I,L} where L where I<:Tuple{Vararg{Union{Int64, AbstractRange{Int64}, Base.AbstractCartesianIndex},N} where N} where A<:Union{Base.ReinterpretArray{T,N,S,A} where S where A<:Union{SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray} where N where T, Base.ReshapedArray{T,N,A,MI} where MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A<:Union{Base.ReinterpretArray{T,N,S,A} where S where A<:Union{SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray} where N where T, SubArray{T,N,A,I,true} where I<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A<:DenseArray where N where T, DenseArray} where N where T, DenseArray}}) where {T<:Union{Complex{Float32}, Complex{Float64}, Float32, Float64}, S} at /Users/sabae/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/LinearAlgebra/src/matmul.jl:106
  *(::LinearAlgebra.Adjoint{#s627,#s626} where #s626<:LinearAlgebra.AbstractTriangular where #s627, ::AbstractArray{T,1} where T) at /Users/sabae/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/LinearAlgebra/src/triangular.jl:1877
  ...
Stacktrace:
 [1] top-level scope at REPL[56]:1

```

Requires significant scrolling to the right to see the entire signature. Does this make sense? I’m running Julia 1.3 on a Mac.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [December 21, 2019, 5:13am UTC](https://discourse.julialang.org/t/unexpectedly-long-method-signature-in-closest-candidates-list/32537/2 "2019-12-21T05:13:22Z")

</div>

What was intended? A dot product? Then do `x'*y`.

---

<div class="post-metadata">

**Author:** ![CameronBieganek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cameronbieganek/32/6915_2.png) [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)\
**Post date:** [December 21, 2019, 5:33am UTC](https://discourse.julialang.org/t/unexpectedly-long-method-signature-in-closest-candidates-list/32537/3 "2019-12-21T05:33:32Z")

</div>

Yeah, sorry I should have been more clear. I know how to do a dot product in Julia. I was just playing around with some stuff in the REPL and I encountered this error message. It seems to me that the way the second “Closest candidate” method is printed in the error message is probably a bug. It’s as if it’s expanding out all the type parameters and/or composite types or something. A method signature shouldn’t be 3629 characters long. This is the full method signature that gets printed out:

> \*(::LinearAlgebra.Adjoint{#s627,#s626} where #s626\<:Union{DenseArray{T,2}, Base.ReinterpretArray{T,2,S,A} where S where A\<:Union{SubArray{T,N,A,I,true} where I\<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A\<:DenseArray where N where T, DenseArray}, Base.ReshapedArray{T,2,A,MI} where MI\<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A\<:Union{Base.ReinterpretArray{T,N,S,A} where S where A\<:Union{SubArray{T,N,A,I,true} where I\<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A\<:DenseArray where N where T, DenseArray} where N where T, SubArray{T,N,A,I,true} where I\<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A\<:DenseArray where N where T, DenseArray}, SubArray{T,2,A,I,L} where L where I\<:Tuple{Vararg{Union{Int64, AbstractRange{Int64}, Base.AbstractCartesianIndex},N} where N} where A\<:Union{Base.ReinterpretArray{T,N,S,A} where S where A\<:Union{SubArray{T,N,A,I,true} where I\<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A\<:DenseArray where N where T, DenseArray} where N where T, Base.ReshapedArray{T,N,A,MI} where MI\<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A\<:Union{Base.ReinterpretArray{T,N,S,A} where S where A\<:Union{SubArray{T,N,A,I,true} where I\<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A\<:DenseArray where N where T, DenseArray} where N where T, SubArray{T,N,A,I,true} where I\<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A\<:DenseArray where N where T, DenseArray} where N where T, DenseArray}} where #s627, ::Union{DenseArray{S,1}, Base.ReinterpretArray{S,1,S1,A} where S1 where A\<:Union{SubArray{T,N,A,I,true} where I\<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A\<:DenseArray where N where T, DenseArray}, Base.ReshapedArray{S,1,A,MI} where MI\<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A\<:Union{Base.ReinterpretArray{T,N,S,A} where S where A\<:Union{SubArray{T,N,A,I,true} where I\<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A\<:DenseArray where N where T, DenseArray} where N where T, SubArray{T,N,A,I,true} where I\<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A\<:DenseArray where N where T, DenseArray}, SubArray{S,1,A,I,L} where L where I\<:Tuple{Vararg{Union{Int64, AbstractRange{Int64}, Base.AbstractCartesianIndex},N} where N} where A\<:Union{Base.ReinterpretArray{T,N,S,A} where S where A\<:Union{SubArray{T,N,A,I,true} where I\<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A\<:DenseArray where N where T, DenseArray} where N where T, Base.ReshapedArray{T,N,A,MI} where MI\<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},N} where N} where A\<:Union{Base.ReinterpretArray{T,N,S,A} where S where A\<:Union{SubArray{T,N,A,I,true} where I\<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A\<:DenseArray where N where T, DenseArray} where N where T, SubArray{T,N,A,I,true} where I\<:Union{Tuple{Vararg{Real,N} where N}, Tuple{AbstractUnitRange,Vararg{Any,N} where N}} where A\<:DenseArray where N where T, DenseArray} where N where T, DenseArray}}) where {T\<:Union{Complex{Float32}, Complex{Float64}, Float32, Float64}, S}

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [December 21, 2019, 10:55am UTC](https://discourse.julialang.org/t/unexpectedly-long-method-signature-in-closest-candidates-list/32537/4 "2019-12-21T10:55:11Z")

</div>

I agree that this should not print like this. You could add this example at

[https://github.com/JuliaLang/julia/issues/32470](https://github.com/JuliaLang/julia/issues/32470)

---

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [December 21, 2019, 11:04am UTC](https://discourse.julialang.org/t/unexpectedly-long-method-signature-in-closest-candidates-list/32537/5 "2019-12-21T11:04:31Z")

</div>

> [@CameronBieganek](#):
>
> A method signature shouldn’t be 3629 characters long

Related:

> [@Why is the strange type signature of sqrt so long?](https://discourse.julialang.org/t/why-is-the-strange-type-signature-of-sqrt-so-long/32541/5):
>
> It is because of StridedArray being a union of a large number of complicated types.

The same also happens with stacktraces and the `methods` function, so it’s really just a display issue.

> <https://github.com/JuliaLang/julia/issues/33065>
>
> Stacktraces are in general pretty hard to read. Here's a list of gripes. I'm not… posting this as separate issues because I don't know what is bug and what is feature here. All tests are on 1.3alpha from an official release. This is related but not the same as https://github.com/JuliaLang/julia/issues/25375, which is about formatting.
> 
> Let's start small:
> 
> \`\`\`
> julia\> sqrt(-2)
> ERROR: DomainError with -2.0:
> sqrt will only return a complex result if called with a complex argument. Try sqrt(Complex(x)).
> Stacktrace:
> \[1\] throw\_complex\_domainerror(::Symbol, ::Float64) at ./math.jl:32
> \[2\] sqrt at ./math.jl:492 \[inlined\]
> \[3\] sqrt(::Int64) at ./math.jl:518
> \[4\] top-level scope at REPL\[4\]:1
> \`\`\`
> \* Where is \`./math.jl\`? 
> \* I don't care that \[2\] is inlined
> \* The last frame is unnecessary (the :1 definitely is, and I don't know what the \[4\] is)
> 
> Now a stdlib:
> \`\`\`
> julia\> lu(\[0 0;0 0\])
> ERROR: SingularException(1)
> Stacktrace:
> \[1\] checknonsingular at /buildworker/worker/package\_linux64/build/usr/share/julia/stdlib/v1.3/LinearAlgebra/src/factorization.jl:19 \[inlined\]
> \[2\] #lu!#128(::Bool, ::typeof(lu!), ::Array{Float64,2}, ::Val{true}) at /buildworker/worker/package\_linux64/build/usr/share/julia/stdlib/v1.3/LinearAlgebra/src/lu.jl:85
> \[3\] #lu! at ./none:0 \[inlined\]
> \[4\] #lu#134(::Bool, ::typeof(lu), ::Array{Int64,2}) at /buildworker/worker/package\_linux64/build/usr/share/julia/stdlib/v1.3/LinearAlgebra/src/lu.jl:295
> \[5\] lu(::Array{Int64,2}) at /buildworker/worker/package\_linux64/build/usr/share/julia/stdlib/v1.3/LinearAlgebra/src/lu.jl:286
> \[6\] top-level scope at REPL\[2\]:1
> \`\`\`
> \* The paths are bad; that means that nice things like ctrl-q will not work, and neither will the functionality in some editors that go to the path.
> \* The keyword arguments lowering, which should really be an implementation detail, is exposed here, and confusing (wtf is \[3\]?)
> 
> \`include\`d user files:
> \`\`\`
> julia\> include("scratch.jl")
> ERROR: LoadError: UndefVarError: qsd not defined
> Stacktrace:
> \[1\] f() at /home/antoine/scratch.jl:2
> \[2\] top-level scope at /home/antoine/scratch.jl:4
> \[3\] include at ./boot.jl:328 \[inlined\]
> \[4\] include\_relative(::Module, ::String) at ./loading.jl:1094
> \[5\] include(::Module, ::String) at ./Base.jl:31
> \[6\] include(::String) at ./client.jl:432
> \[7\] top-level scope at REPL\[3\]:1
> in expression starting at /home/antoine/scratch.jl:4
> \`\`\`
> \* Five frames for the include are hard to read
> \* Having the information at the bottom is confusing: where am I supposed to find the source of the error? In the stacktrace or at the bottom?
> \* The LoadError: UndefVarError is annoying (it gets worse for more complex cases, ie multiple includes)
> 
> Failing tests:
> \`\`\`
> ERROR: LoadError: LoadError: LoadError: DomainError with -2.0:
> sqrt will only return a complex result if called with a complex argument. Try sqrt(Complex(x)).
> Stacktrace:
> \[1\] throw\_complex\_domainerror(::Symbol, ::Float64) at ./math.jl:32
> \[2\] sqrt at ./math.jl:492 \[inlined\]
> \[3\] sqrt(::Int64) at ./math.jl:518
> \[4\] @SArray(::LineNumberNode, ::Module, ::Any) at /home/antoine/.julia/packages/StaticArrays/3KEjZ/src/SArray.jl:83
> \[5\] include at ./boot.jl:328 \[inlined\]
> \[6\] include\_relative(::Module, ::String) at ./loading.jl:1094
> \[7\] include(::Module, ::String) at ./Base.jl:31
> \[8\] include(::String) at ./client.jl:432
> \[9\] top-level scope at /home/antoine/.julia/packages/StaticArrays/3KEjZ/test/runtests.jl:19
> \[10\] include at ./boot.jl:328 \[inlined\]
> \[11\] include\_relative(::Module, ::String) at ./loading.jl:1094
> \[12\] include(::Module, ::String) at ./Base.jl:31
> \[13\] include(::String) at ./client.jl:432
> \[14\] top-level scope at none:5
> in expression starting at /home/antoine/.julia/packages/StaticArrays/3KEjZ/test/SArray.jl:30
> in expression starting at /home/antoine/.julia/packages/StaticArrays/3KEjZ/test/SArray.jl:1
> in expression starting at /home/antoine/.julia/packages/StaticArrays/3KEjZ/test/runtests.jl:19
> ERROR: Package StaticArrays errored during testing
> \`\`\`
> I'm a bit confused about what's going on here to be honest... 
> 
> 
> I did not try with the other ways of including code, macros, etc. So, to sum up, in subjective increasing order of seriousness
> \* There are minor printing things that could be nicer: REPL frames, LoadError nesting, inline, \`./\` path for base
> \* The keyword argument lowering is a bit nasty
> \* The paths on official releases should be corrected
> \* The stacktraces with \`include\` are very hard to parse. This is possibly the most controversial issue because enhancing this would mean "lying" to the user, ie treating \`include\` as a special function
