# Inner constructor with type parameter not in signature

**URL:** <https://discourse.julialang.org/t/inner-constructor-with-type-parameter-not-in-signature/1413>\
**Category:** General Usage\
**Tags:** question\
**Created:** [January 11, 2017, 12:15pm UTC](https://discourse.julialang.org/t/inner-constructor-with-type-parameter-not-in-signature/1413 "2017-01-11T12:15:30Z")\
**Posts on this page:** 3\
**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:** [January 11, 2017, 12:15pm UTC](https://discourse.julialang.org/t/inner-constructor-with-type-parameter-not-in-signature/1413/1 "2017-01-11T12:15:30Z")

</div>

I would like to “store” some information (basically, a tuple of symbols) in a type parameter, eg

```julia
immutable Foo{X} end

```

which works:

```julia
julia> Foo{(:A)}()
Foo{:A}()

```

But at the same time I also want to use an inner constructor to check it:

```julia
immutable Foo2{X}
    function Foo2{X}()
        @assert isa(X, Tuple{Vararg{Symbol}}) && length(X) == 3
        new{X}()
    end
end

```

for which I get

```julia
WARNING: static parameter X does not occur in signature for Type at REPL[108]:3.
The method will not be callable.

```

Is there a way I can get both, ie a validating inner constructor **and** a type parameter that is not in the signature? Of course in practice I would use an outer constructor, I want to do something like

```julia
Foo2((:a,:b,:c)) # OK
Foo2((:a,1)) # error

```

---

<div class="post-metadata">

**Author:** ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)\
**Post date:** [January 11, 2017, 12:38pm UTC](https://discourse.julialang.org/t/inner-constructor-with-type-parameter-not-in-signature/1413/2 "2017-01-11T12:38:14Z")

</div>

`X` is already defined inside the type-declaration:

```julia
julia> immutable Foo2{X}
           function Foo2(); @show X
               @assert isa(X, Tuple{Vararg{Symbol}}) && length(X) == 3
               new()
           end
       end

julia> Foo2{(:a,:b,:c)}()
X = (:a,:b,:c)
Foo2{(:a,:b,:c)}()

julia> Foo2{(:a,:b)}()
X = (:a,:b)
------ AssertionError ------------------ Stacktrace (most recent call last)

 [1] — Foo2{(:a,:b)}() at REPL[1]:3

AssertionError: isa(X,Tuple{Vararg{Symbol}}) && length(X) == 3

```

---

<div class="post-metadata">

**Author:** ![fengyang.wang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fengyang.wang/32/104_2.png) [@fengyang.wang](https://discourse.julialang.org/u/fengyang.wang)\
**Post date:** [April 15, 2017, 5:36am UTC](https://discourse.julialang.org/t/inner-constructor-with-type-parameter-not-in-signature/1413/3 "2017-04-15T05:36:53Z")

</div>

This is a case where the implicit inner constructors of 0.5 are really unfortunate. In 0.6, implicit inner constructors are deprecated, and hopefully eventually (maybe 2.0) the code in your original post will work.
