# Warning for unused type variables in where

**URL:** https://discourse.julialang.org/t/warning-for-unused-type-variables-in-where/30360
**Category:** Internals & Design
**Tags:** question
**Created:** [October 27, 2019, 9:47am UTC](https://discourse.julialang.org/t/warning-for-unused-type-variables-in-where/30360 "2019-10-27T09:47:47Z")
**Posts on this page:** 4
**Page:** 1

<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: [October 27, 2019, 9:47am UTC](https://discourse.julialang.org/t/warning-for-unused-type-variables-in-where/30360/1 "2019-10-27T09:47:47Z")

</div>

I am wondering whether it would make sense to warn unused extra type variables for cases like

```julia
foo(a::AbstractVector{T}) where {T,S} = 1

```

where it is very likely that `S` is a typo.

It is certainly innocuous as long as it is not used (and then one gets an error), this would just be a convenience feature.

(asking here because I could not find an issue about this)

---

<div class="post-metadata">

### Author: ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)
#### Post date: [October 27, 2019, 1:08pm UTC](https://discourse.julialang.org/t/warning-for-unused-type-variables-in-where/30360/2 "2019-10-27T13:08:29Z")

</div>

Like all other similar features, it should either

1. Off by default, turn on with cmdline arg or env, or
2. Have a way to turn it off in the code, or
3. Be an error

As of now, an external tool like linter is a much better place for it.

---

<div class="post-metadata">

### Author: ![tkf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkf/32/17635_2.png) [@tkf](https://discourse.julialang.org/u/tkf)
#### Post date: [October 29, 2019, 1:56am UTC](https://discourse.julialang.org/t/warning-for-unused-type-variables-in-where/30360/3 "2019-10-29T01:56:03Z")

</div>

How about using `Test.detect_unbound_args`?

```julia
julia> module Demo
       bad(a::AbstractVector{T}) where {T,S} = 1
       good(a::AbstractVector{T}) where {T} = 1
       end
Main.Demo

julia> detect_unbound_args(Demo)
[1] bad(a::AbstractArray{T,1}) where {T, S} in Main.Demo at REPL[121]:2

```

FYI I wrote a convenient wrapper for this and similar automatable checks: [https://github.com/tkf/Aqua.jl](https://github.com/tkf/Aqua.jl) (required to workaround [https://github.com/JuliaLang/julia/pull/31972](https://github.com/JuliaLang/julia/pull/31972))

---

<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: [October 29, 2019, 7:21am UTC](https://discourse.julialang.org/t/warning-for-unused-type-variables-in-where/30360/4 "2019-10-29T07:21:11Z")

</div>

That’s very helpful, thanks.

From this discussion, I realized that functionality like this should live in a linter, and user who want this are best served by making linting automated and easy to use, possibly as part of CI. You package does exactly this.
