# Overwrittng constant parameter restriction in method definition

**URL:** <https://discourse.julialang.org/t/overwrittng-constant-parameter-restriction-in-method-definition/20721>\
**Category:** Internals & Design\
**Tags:** question\
**Created:** [February 12, 2019, 7:01pm UTC](https://discourse.julialang.org/t/overwrittng-constant-parameter-restriction-in-method-definition/20721 "2019-02-12T19:01:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bkamins](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bkamins/32/208538_2.png) [@bkamins](https://discourse.julialang.org/u/bkamins)\
**Post date:** [February 12, 2019, 7:01pm UTC](https://discourse.julialang.org/t/overwrittng-constant-parameter-restriction-in-method-definition/20721/1 "2019-02-12T19:01:17Z")

</div>

Following the question asked here [Propagate Type Parameters in Methods for Julia - Stack Overflow](https://stackoverflow.com/questions/54655864/propagate-type-parameters-in-methods-for-julia).

If you define a constant like

```julia
const RT{R<:Real} = Type{R}

```

then defining a method using this constant without a parameter

```julia
rt(r::RT) = r

```

keeps the type restriction, which can be seen by inspecting the defined method:

```julia
julia> methods(rt)
# 1 method for generic function "rt":
[1] rt(::Type{R} where R<:Real) in Main at REPL[16]:1

```

However, if you can overwrite this restriction when defining a method like this:

```julia
julia> methods(rt2)
# 1 method for generic function "rt2":
[1] rt2(::Type{R}) where R<:AbstractString in Main at REPL[29]:1

julia> rt3(::RT{R} where {R <: AbstractString}) = R
rt3 (generic function with 1 method)

julia> methods(rt3)
# 1 method for generic function "rt3":
[1] rt3(::Type{R} where R<:AbstractString) in Main at REPL[31]:1

```

Is this behavior indented?

---

<div class="post-metadata">

**Author:** ![jeff.bezanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeff.bezanson/32/48_2.png) [@jeff.bezanson](https://discourse.julialang.org/u/jeff.bezanson)\
**Post date:** [February 13, 2019, 10:57pm UTC](https://discourse.julialang.org/t/overwrittng-constant-parameter-restriction-in-method-definition/20721/2 "2019-02-13T22:57:44Z")

</div>

I would say it is intended, but not desired 🙂 See issue [https://github.com/JuliaLang/julia/issues/6383](https://github.com/JuliaLang/julia/issues/6383). I do plan to address this somehow eventually. The tricky part is that we can’t really compare types with free variables, so it’s not clear what the rules should be. For example say we have

```julia
const RT{T<:AbstractArray} = Vector{T}

```

Then a constraint like `RT{S} where S<:Array{T} where ...` is probably valid, but `RT{S} where S<:AbstractDict where ...` probably isn’t.
