# How does Julia invoke constructors with overlapping constraints

**URL:** https://discourse.julialang.org/t/how-does-julia-invoke-constructors-with-overlapping-constraints/134243
**Category:** New to Julia
**Created:** [November 30, 2025, 8:41pm UTC](https://discourse.julialang.org/t/how-does-julia-invoke-constructors-with-overlapping-constraints/134243 "2025-11-30T20:41:13Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![RCh](https://avatars.discourse-cdn.com/v4/letter/r/919ad9/32.png) [@RCh](https://discourse.julialang.org/u/RCh)
#### Post date: [December 1, 2025, 8:30pm UTC](https://discourse.julialang.org/t/how-does-julia-invoke-constructors-with-overlapping-constraints/134243/5 "2025-12-01T20:30:21Z")

</div>

Seems, that I was able to do it, but I don’t know if this approach is correct, not sure how many types will be crated based on SIZE.

```julia-auto
mutable struct Context{TYPE_VAR_STACK <: Union{UInt8, UInt16}, N <:Union{UInt8, UInt16}, SIZE}
    stack::SizedVector{SIZE, TYPE_VAR_STACK}
    index::N 

    function Context(stack_type::Type{T}, stack_length::N, def_stack_val::T=eltype(stack_type)(0)) where {T <: Union{UInt8, UInt16}, N <: Union{UInt8, UInt16}}
        # StaticArrays pkg doesn't allow to have its Size in different types than Int
        size = Int64(stack_length)
        stack = SizedVector{size, stack_type}(fill(def_stack_val, size))
        return new{T, N, size}(stack, firstindex(stack))
    end
end

julia> sdd = Context(UInt16, UInt16(1200), UInt16(33))
Context{UInt16, UInt16, 1200}(UInt16[0x0021, 0x0021, 0x0021, 0x0021, 0x0021, 0x0021, 0x0021, 0x0021, 0x0021, 0x0021 … 0x0021, 0x0021, 0x0021, 0x0021, 0x0021, 0x0021, 0x0021, 0x0021, 0x0021, 0x0021], 0x0001)

```

---

_[View the full topic](https://discourse.julialang.org/t/how-does-julia-invoke-constructors-with-overlapping-constraints/134243)._
