# Inconsistent behaviour of Vararg UnionAll

**URL:** https://discourse.julialang.org/t/inconsistent-behaviour-of-vararg-unionall/31644
**Category:** General Usage
**Tags:** question
**Created:** [November 29, 2019, 6:53am UTC](https://discourse.julialang.org/t/inconsistent-behaviour-of-vararg-unionall/31644 "2019-11-29T06:53:38Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![schlichtanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/schlichtanders/32/32145_2.png) [@schlichtanders](https://discourse.julialang.org/u/schlichtanders)
#### Post date: [November 29, 2019, 6:53am UTC](https://discourse.julialang.org/t/inconsistent-behaviour-of-vararg-unionall/31644/1 "2019-11-29T06:53:38Z")

</div>

dear out there,

I just stumbled upon the maybe most weird julia bug I experienced so far

```julia
f1(args::(Vararg{Any, N} where N); kwargs...) = (args, kwargs)
f2(args::(Vararg{Any, N} where N)) = (args, 1)
f3(args::(Vararg{Any}); kwargs...) = (args, kwargs)

@show f1(1,2,3) f2(1,2,3) f3(1,2,3)

```

will print

```julia
f1(1, 2, 3) = (((1, 2, 3),), Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}())
f2(1, 2, 3) = ((1, 2, 3), 1)
f3(1, 2, 3) = ((1, 2, 3), Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}())

```

The core difference is that for `f1` the args get packed into an EXTRA level of Tuple…

Super weird, especially because

- `f1` and `f2` share the same type on `args` and
- `f1` and `f3` share in principle the same type on `args` (as the first is an explicit UnionAll, and the second the respective implicit UnionAll)

ideas?

EDIT:  
Question for building a workaround:  
Is there a way to easily normalize the explicit UnionAll `Vararg{Any, N} where N` into the correct behaving `Vararg{Any}`?

version: this run on julia 1.2.0

---

<div class="post-metadata">

### Author: ![schlichtanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/schlichtanders/32/32145_2.png) [@schlichtanders](https://discourse.julialang.org/u/schlichtanders)
#### Post date: [November 29, 2019, 7:01am UTC](https://discourse.julialang.org/t/inconsistent-behaviour-of-vararg-unionall/31644/2 "2019-11-29T07:01:04Z")

</div>

it gets even weirder, just tested equality:

`Vararg{Any} === Vararg{Any, N} where N`  
gives `true`

---

<div class="post-metadata">

### Author: ![schlichtanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/schlichtanders/32/32145_2.png) [@schlichtanders](https://discourse.julialang.org/u/schlichtanders)
#### Post date: [November 30, 2019, 7:22am UTC](https://discourse.julialang.org/t/inconsistent-behaviour-of-vararg-unionall/31644/3 "2019-11-30T07:22:17Z")

</div>

opened as bug report at [https://github.com/JuliaLang/julia/issues/33987](https://github.com/JuliaLang/julia/issues/33987)

---

<div class="post-metadata">

### Author: ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)
#### Post date: [November 30, 2019, 9:46am UTC](https://discourse.julialang.org/t/inconsistent-behaviour-of-vararg-unionall/31644/4 "2019-11-30T09:46:07Z")

</div>

```julia
julia> f4(args::(Vararg{Any, N}); kwargs...) where {N} = (args, kwargs)
f4 (generic function with 1 method)

julia> @show f1(1,2,3) f3(1,2,3) f4(1,2,3);
f1(1, 2, 3) = (((1, 2, 3),), Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}())
f3(1, 2, 3) = ((1, 2, 3), Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}())
f4(1, 2, 3) = ((1, 2, 3), Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}())

```
