<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="julia&gt; versioninfo()
Julia Version 1.3.0-rc4.1
Commit 8c4656b97a (2019-10-15 14:08 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, skylake)
Environment:
  JULIA_CMDSTAN_HOME = /home/tamas/src/cmdstan/"><pre class="notranslate">julia<span class="pl-k">&gt;</span> <span class="pl-c1">versioninfo</span>()
Julia Version <span class="pl-c1">1.3</span>.<span class="pl-c1">0</span><span class="pl-k">-</span>rc4.<span class="pl-c1">1</span>
Commit <span class="pl-c1">8</span>c4656b97a (<span class="pl-c1">2019</span><span class="pl-k">-</span><span class="pl-c1">10</span><span class="pl-k">-</span><span class="pl-c1">15</span> <span class="pl-c1">14</span><span class="pl-k">:</span><span class="pl-c1">08</span> UTC)
Platform Info<span class="pl-k">:</span>
  OS<span class="pl-k">:</span> Linux (x86_64<span class="pl-k">-</span>linux<span class="pl-k">-</span>gnu)
  CPU<span class="pl-k">:</span> <span class="pl-c1">Intel</span>(R) <span class="pl-c1">Core</span>(TM) i5<span class="pl-k">-</span><span class="pl-c1">8250</span>U CPU @ <span class="pl-c1">1.60</span>GHz
  WORD_SIZE<span class="pl-k">:</span> <span class="pl-c1">64</span>
  LIBM<span class="pl-k">:</span> libopenlibm
  LLVM<span class="pl-k">:</span> libLLVM<span class="pl-k">-</span><span class="pl-c1">6.0</span>.<span class="pl-c1">1</span> (ORCJIT, skylake)
Environment<span class="pl-k">:</span>
  JULIA_CMDSTAN_HOME <span class="pl-k">=</span> <span class="pl-k">/</span>home<span class="pl-k">/</span>tamas<span class="pl-k">/</span>src<span class="pl-k">/</span>cmdstan<span class="pl-k">/</span></pre></div>
<p dir="auto">MWE condensed from <a href="https://discourse.julialang.org/t/type-stable-zip-of-tuple/30105" rel="nofollow">discussion</a>:</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="using Test

# wrapper is pretty much irrelevant for the problem, just to make an MWE
@inline wrapper(itrs) = sum(prod(first.(i)) for i in Iterators.product(itrs...))

zipped1(pairs) = wrapper(map(pair -&gt; zip(pair...), pairs))

zipped2(pairs) = wrapper(map(pair -&gt; zip(pair[1], pair[2]), pairs))

pairs = (1:5 =&gt; 1:5, 2:3 =&gt; 2:3)

@inferred zipped1(pairs) # ERROR: return type Int64 does not match inferred return type Any
@inferred zipped2(pairs) # inferred correctly"><pre class="notranslate"><span class="pl-k">using</span> Test

<span class="pl-c"><span class="pl-c">#</span> wrapper is pretty much irrelevant for the problem, just to make an MWE</span>
<span class="pl-c1">@inline</span> <span class="pl-en">wrapper</span>(itrs) <span class="pl-k">=</span> <span class="pl-c1">sum</span>(<span class="pl-c1">prod</span>(<span class="pl-c1">first</span>.(i)) <span class="pl-k">for</span> i <span class="pl-k">in</span> Iterators<span class="pl-k">.</span><span class="pl-c1">product</span>(itrs<span class="pl-k">...</span>))

<span class="pl-en">zipped1</span>(pairs) <span class="pl-k">=</span> <span class="pl-c1">wrapper</span>(<span class="pl-c1">map</span>(pair <span class="pl-k">-&gt;</span> <span class="pl-c1">zip</span>(pair<span class="pl-k">...</span>), pairs))

<span class="pl-en">zipped2</span>(pairs) <span class="pl-k">=</span> <span class="pl-c1">wrapper</span>(<span class="pl-c1">map</span>(pair <span class="pl-k">-&gt;</span> <span class="pl-c1">zip</span>(pair[<span class="pl-c1">1</span>], pair[<span class="pl-c1">2</span>]), pairs))

pairs <span class="pl-k">=</span> (<span class="pl-c1">1</span><span class="pl-k">:</span><span class="pl-c1">5</span> <span class="pl-k">=&gt;</span> <span class="pl-c1">1</span><span class="pl-k">:</span><span class="pl-c1">5</span>, <span class="pl-c1">2</span><span class="pl-k">:</span><span class="pl-c1">3</span> <span class="pl-k">=&gt;</span> <span class="pl-c1">2</span><span class="pl-k">:</span><span class="pl-c1">3</span>)

<span class="pl-c1">@inferred</span> <span class="pl-c1">zipped1</span>(pairs) <span class="pl-c"><span class="pl-c">#</span> ERROR: return type Int64 does not match inferred return type Any</span>
<span class="pl-c1">@inferred</span> <span class="pl-c1">zipped2</span>(pairs) <span class="pl-c"><span class="pl-c">#</span> inferred correctly</span></pre></div>
<p dir="auto">I found some similar-looking issues, but this did not look like a duplicate of any of them.</p>
<p dir="auto">In a few places, the performance of splatting a number has shown up: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="357406108" data-permission-text="Title is private" data-url="https://github.com/JuliaLang/julia/issues/29060" data-hovercard-type="pull_request" data-hovercard-url="/JuliaLang/julia/pull/29060/hovercard" href="https://github.com/JuliaLang/julia/pull/29060">#29060</a>,  <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="351903955" data-permission-text="Title is private" data-url="https://github.com/JuliaLang/julia/issues/28764" data-hovercard-type="pull_request" data-hovercard-url="/JuliaLang/julia/pull/28764/hovercard?comment_id=419917783&amp;comment_type=issue_comment" href="https://github.com/JuliaLang/julia/pull/28764#issuecomment-419917783">#28764 (comment)</a> and working around this give signficiant speed-ups.<br>
The code is well inferred but there is a call to <code class="notranslate">_apply</code> instead of the actual method. This dissapears if the number is wrapped in a tuple.</p>
<p dir="auto">It would be nice to have this fixed so these type of workarounds are no longer needed.</p>
<p dir="auto">Ref <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="329345982" data-permission-text="Title is private" data-url="https://github.com/JuliaLang/julia/issues/27434" data-hovercard-type="pull_request" data-hovercard-url="/JuliaLang/julia/pull/27434/hovercard?comment_id=400335764&amp;comment_type=issue_comment" href="https://github.com/JuliaLang/julia/pull/27434#issuecomment-400335764">#27434 (comment)</a></p>
<p dir="auto">cc <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/mbauman/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/mbauman">@mbauman</a>, <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/martinholters/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/martinholters">@martinholters</a></p>