# Small union type failure

**URL:** <https://discourse.julialang.org/t/small-union-type-failure/18640>\
**Category:** General Usage\
**Created:** [December 13, 2018, 9:30pm UTC](https://discourse.julialang.org/t/small-union-type-failure/18640 "2018-12-13T21:30:27Z")\
**Posts on this page:** 1\
**Showing post:** 6

<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:** [December 14, 2018, 9:17am UTC](https://discourse.julialang.org/t/small-union-type-failure/18640/6 "2018-12-14T09:17:48Z")

</div>

I wonder if something along the lines of

```julia
function Base._promote_typejoin(::Type{S}, ::Type{T}) where {S, T}
    _cs(T, S) = (isconcretetype(T) || T ≡ Union{}) && Base.issingletontype(S)
    if _cs(T, S) || _cs(S, T)
        Union{T, S}
    else
        typejoin(S, T)
    end
end

```

would work, generalizing the existing cases to the union of a concrete and a singleton type.

---

_[View the full topic](https://discourse.julialang.org/t/small-union-type-failure/18640)._
