# Inner parametric type constructor not defined error

**URL:** <https://discourse.julialang.org/t/inner-parametric-type-constructor-not-defined-error/52592>\
**Category:** General Usage\
**Tags:** question, parametric-types\
**Created:** [December 29, 2020, 10:12pm UTC](https://discourse.julialang.org/t/inner-parametric-type-constructor-not-defined-error/52592 "2020-12-29T22:12:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mkarikom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkarikom/32/7096_2.png) [@mkarikom](https://discourse.julialang.org/u/mkarikom)\
**Post date:** [December 29, 2020, 10:12pm UTC](https://discourse.julialang.org/t/inner-parametric-type-constructor-not-defined-error/52592/1 "2020-12-29T22:12:58Z")

</div>

I have the following parametric type `newInt`, which works, but adding an inner constructor that fills in certain fields causes errors:

```julia
struct newInt{U,V}
    u::U
    v::V
    n::DataType
end

julia> newInt(10,"a",String)
newInt{Int64,String}(10, "a", String)

struct newInt2{U,V}
    u::U
    v::V
    n::DataType
    newInt2{U,V}(u::U,v::V) where {U,V} = new(u,v,typeof(v))
end

julia> newInt2(10,"a")
ERROR: MethodError: no method matching newInt2(::Int64, ::String)

```

---

<div class="post-metadata">

**Author:** ![Skoffer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/skoffer/32/378_2.png) [@Skoffer](https://discourse.julialang.org/u/Skoffer)\
**Post date:** [December 29, 2020, 10:41pm UTC](https://discourse.julialang.org/t/inner-parametric-type-constructor-not-defined-error/52592/2 "2020-12-29T22:41:50Z")

</div>

Inner constructor defined in such a way, that you need to use following construction

```julia
newInt2{Int, String}(10, "a")

```

But you do not need inner constructor at all, you can define usual outer constructor

```julia
newInt2(u::U,v::V) where {U,V} = newInt2(u,v, V)

```
