# Stack overflow error when splatting strings into \`join\`

**URL:** <https://discourse.julialang.org/t/stack-overflow-error-when-splatting-strings-into-join/4322>\
**Category:** General Usage\
**Created:** [June 17, 2017, 7:51am UTC](https://discourse.julialang.org/t/stack-overflow-error-when-splatting-strings-into-join/4322 "2017-06-17T07:51:53Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [June 17, 2017, 7:51am UTC](https://discourse.julialang.org/t/stack-overflow-error-when-splatting-strings-into-join/4322/1 "2017-06-17T07:51:53Z")

</div>

I accidentally splatted several strings into `join`, and got the following behaviour, with many screens of error messages scrolling past:

```julia

julia> join('a', 'b', 'c')
"a"

julia> join('a', 'b', 'c', 'd')

ERROR: StackOverflowError:
Stacktrace:
 [1] join(::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Vararg{Any,N} where N) at ./strings/io.jl:216
 [2] #sprint#228(::Void, ::Function, ::Int64, ::Function, ::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Vararg{Any,N} where N) at ./strings/io.jl:66

```

I just want to understand, is this the kind of thing that should be filed as an issue? It doesn’t seem like the most useful error message.

---

<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:** [June 17, 2017, 8:28am UTC](https://discourse.julialang.org/t/stack-overflow-error-when-splatting-strings-into-join/4322/2 "2017-06-17T08:28:23Z")

</div>

> [@DNF](#):
>
> join(‘a’, ‘b’, ‘c’, ‘d’)

This goes through

```julia
join(IOBuffer(Base.StringVector(0), true, true), 'a', 'b', 'c', 'd')

```

and that’s why you get the infinite recursion. Passing around `args...` is useful for compact code, but sometimes leads to cryptic error messages. Perhaps an idiom that allowed passing a bunch of arguments in groups, not unlike [COMMON-LISP:&WHOLE](http://clhs.lisp.se/Body/03_dd.htm), would be helpful?

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [June 17, 2017, 8:30am UTC](https://discourse.julialang.org/t/stack-overflow-error-when-splatting-strings-into-join/4322/3 "2017-06-17T08:30:58Z")

</div>

But you don’t think it’s a reportable bug, but expected behaviour?

---

<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:** [June 17, 2017, 9:03am UTC](https://discourse.julialang.org/t/stack-overflow-error-when-splatting-strings-into-join/4322/4 "2017-06-17T09:03:16Z")

</div>

I think there is an issue here that is worth discussion, ie how to implement this rather common pattern so that it leads to better output from `methods` (`join(args...)` is not really informative), better error reporting, etc. So perhaps open an issue, after checking that it does not exist, about this broader question.

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [June 17, 2017, 9:04am UTC](https://discourse.julialang.org/t/stack-overflow-error-when-splatting-strings-into-join/4322/5 "2017-06-17T09:04:58Z")

</div>

It’s worth reporting, or even better make a PR. It should really be a MethodError and replacing the `join(args...)` catchall method with specific versions for one to three arguments would solve it. Alternatively a `join(io::IO, args...)` method could be added to stop the recursion and throw an error.

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [June 17, 2017, 10:30am UTC](https://discourse.julialang.org/t/stack-overflow-error-when-splatting-strings-into-join/4322/6 "2017-06-17T10:30:49Z")

</div>

I didn’t ever use `join` a lot, but according to the documentation it’s supposed to take an array (or any iterable) as input, no?

```julia
julia> join(('a', 'b', 'c', 'd'))
"abcd"

julia> join(['a', 'b', 'c', 'd'])
"abcd"

julia> join(["a", "b", "c", "d"])
"abcd"

julia> join(("a", "b", "c", "d"))
"abcd"

```

---

<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:** [June 17, 2017, 10:33am UTC](https://discourse.julialang.org/t/stack-overflow-error-when-splatting-strings-into-join/4322/7 "2017-06-17T10:33:05Z")

</div>

Yes, the issue here is the error message…
