# Method / Type error verbosity & semantics

**URL:** https://discourse.julialang.org/t/method-type-error-verbosity-semantics/81039
**Category:** Internals & Design
**Tags:** question, semantic
**Created:** [May 13, 2022, 6:56pm UTC](https://discourse.julialang.org/t/method-type-error-verbosity-semantics/81039 "2022-05-13T18:56:13Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![bcon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bcon/32/23495_2.png) [@bcon](https://discourse.julialang.org/u/bcon)
#### Post date: [May 13, 2022, 6:56pm UTC](https://discourse.julialang.org/t/method-type-error-verbosity-semantics/81039/1 "2022-05-13T18:56:13Z")

</div>

An enhancement question:  
Can the types displayed in MethodErrors be made more succinct? In using Unitful, 99% of the time arguments are called with the wrong unit type and it would be great to display type symbols rather than the full signature.

Eg, with `Radian` [defined in](https://github.com/PainterQubits/Unitful.jl/blob/492c4756e2b2c0668f7693bc786b121ba318b085/src/pkgdefaults.jl),

```julia
using Unitful
f(a::Unitful.Length) = @show a
julia> f(1u"rad")

```

currently gives

```julia
ERROR: MethodError: no method matching f(::Quantity{Int64, NoDims, Unitful.FreeUnits{(rad,), NoDims, nothing}})
Closest candidates are:
  f(::Union{Quantity{T, 𝐋, U}, Level{L, S, Quantity{T, 𝐋, U}} where {L, S}} where {T, U}) at REPL[2]:1

julia> f(1)
ERROR: MethodError: no method matching f(::Int64)
Closest candidates are:
  f(::Union{Quantity{T, 𝐋, U}, Level{L, S, Quantity{T, 𝐋, U}} where {L, S}} where {T, U}) at REPL[2]:1

```

I’d like instead:

```julia
julia> f(1u"rad")
ERROR: MethodError: no method matching f(::Radian)
Closest candidates are:
  f(::Radian)

```

Is this limited by julia’s type handling / error machinery, which have no knowledge of or ability to receive a human-friendly type name?

Stated differently, I’d prefer to display the most Abstract type rather than the most primitive in the type tree. If I define

```julia
julia> abstract type Length <: Unitful.Length end # this line doesn't work, I can't figure out the right definition...
julia> g(a::Length) = @show a

```

it’s more natural to show MethodErrors using the AbstractType in the function parameter types than showing their resolved type, which the user shouldn’t need to know.  
(To be clear, using type machinery to model physical units is not a quixotic search for performance; instead it is to use a language and environment feature to help users manage complexity and increase productivity.)

---

<div class="post-metadata">

### Author: ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)
#### Post date: [May 13, 2022, 10:12pm UTC](https://discourse.julialang.org/t/method-type-error-verbosity-semantics/81039/2 "2022-05-13T22:12:11Z")

</div>

Something like that would need to be opt-in, probably. As many people would like their error messages to be precise.
