<p dir="auto">I believe the following behavior of <code class="notranslate">which()</code> is not intended:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="julia&gt; f(a::Int, b) = a+b
f (generic function with 1 method)

julia&gt; f(a, b::Int) = a-b
f (generic function with 2 methods)

julia&gt; f(2,2) # to highlight that there is an ambiguity
ERROR: MethodError: f(::Int64, ::Int64) is ambiguous. Candidates:
  f(a, b::Int64) in Main at REPL[2]:1
  f(a::Int64, b) in Main at REPL[1]:1
Possible fix, define
  f(::Int64, ::Int64)

julia&gt; which(f, Tuple{Int,Int})
ERROR: no method found for the specified argument types
Stacktrace:
 [1] which(::Any, ::Any) at ./reflection.jl:823"><pre class="notranslate"><code class="notranslate">julia&gt; f(a::Int, b) = a+b
f (generic function with 1 method)

julia&gt; f(a, b::Int) = a-b
f (generic function with 2 methods)

julia&gt; f(2,2) # to highlight that there is an ambiguity
ERROR: MethodError: f(::Int64, ::Int64) is ambiguous. Candidates:
  f(a, b::Int64) in Main at REPL[2]:1
  f(a::Int64, b) in Main at REPL[1]:1
Possible fix, define
  f(::Int64, ::Int64)

julia&gt; which(f, Tuple{Int,Int})
ERROR: no method found for the specified argument types
Stacktrace:
 [1] which(::Any, ::Any) at ./reflection.jl:823
</code></pre></div>
<p dir="auto">Instead of saying that there is "no method found", <code class="notranslate">which()</code> should give an error indicating that there is an ambiguity. Looking at the source </p><div class="Box Box--condensed my-2">
  <div class="Box-header f6">
    <p class="mb-0 text-bold">
      <a href="https://github.com/JuliaLang/julia/blob/2b983d41f064c39c0b73f6c7695cc13e0de45c03/base/reflection.jl#L878">julia/base/reflection.jl</a>
    </p>
    <p class="mb-0 color-fg-muted">
         Line 878
      in
      <a data-pjax="true" class="commit-tease-sha" href="/JuliaLang/julia/commit/2b983d41f064c39c0b73f6c7695cc13e0de45c03">2b983d4</a>
    </p>
  </div>
  <div itemprop="text" class="Box-body p-0 blob-wrapper blob-wrapper-embedded data">
    <table class="highlight tab-size mb-0 js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">

        <tbody><tr class="border-0">
          <td id="L878" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="878"></td>
          <td id="LC878" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c1">error</span>(<span class="pl-s"><span class="pl-pds">"</span>method match is ambiguous for the specified argument types<span class="pl-pds">"</span></span>) </td>
        </tr>
    </tbody></table>
  </div>
</div>
, it looks like an ambiguity error was intended. Blame shows that none of this code has changed for a while.<p></p>
<p dir="auto">I think it's worth fixing or changing the error to say that it might be an ambiguity because it was quite confusing to me when debugging.</p>
<p dir="auto">Sorry if this is a duplicate issue - it's not too easy to search for issues involving "which".</p>
<p dir="auto">Also, my <code class="notranslate">versioninfo()</code>:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Julia Version 0.6.0
Commit 9036443 (2017-06-19 13:05 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-2720QM CPU @ 2.20GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Sandybridge)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, sandybridge)"><pre class="notranslate"><code class="notranslate">Julia Version 0.6.0
Commit 9036443 (2017-06-19 13:05 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-2720QM CPU @ 2.20GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Sandybridge)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, sandybridge)
</code></pre></div>
<p dir="auto">As pointed out here <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="80269034" data-permission-text="Title is private" data-url="https://github.com/JuliaLang/julia/issues/11430" data-hovercard-type="pull_request" data-hovercard-url="/JuliaLang/julia/pull/11430/hovercard?comment_id=105062641&amp;comment_type=issue_comment" href="https://github.com/JuliaLang/julia/pull/11430#issuecomment-105062641">#11430 (comment)</a>, here <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="80269034" data-permission-text="Title is private" data-url="https://github.com/JuliaLang/julia/issues/11430" data-hovercard-type="pull_request" data-hovercard-url="/JuliaLang/julia/pull/11430/hovercard?comment_id=105281450&amp;comment_type=issue_comment" href="https://github.com/JuliaLang/julia/pull/11430#issuecomment-105281450">#11430 (comment)</a> and in some of the comments on that issue, the naming convention for <code class="notranslate">Ref</code> and <code class="notranslate">RefValue</code> is probably not the best and causes some confusion.</p>
<p dir="auto">I'd like to propose the following changes</p>
<ul dir="auto">
<li><code class="notranslate">Ref</code> -&gt; <code class="notranslate">CRef</code>, <code class="notranslate">ARef</code> (A for Abstract) or <code class="notranslate">ByRef</code> (proposed by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/JeffBezanson/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/JeffBezanson">@JeffBezanson</a>)</li>
<li><code class="notranslate">RefValue</code> -&gt; <code class="notranslate">Ref</code> (and export this)</li>
</ul>
<p dir="auto">and leaving <code class="notranslate">RefArray</code> as it is.</p>
<p dir="auto">As pointed out by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/vtjnash/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/vtjnash">@vtjnash</a>, most of the time what people need is the abstract version, but for <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="80269034" data-permission-text="Title is private" data-url="https://github.com/JuliaLang/julia/issues/11430" data-hovercard-type="pull_request" data-hovercard-url="/JuliaLang/julia/pull/11430/hovercard" href="https://github.com/JuliaLang/julia/pull/11430">#11430</a> and <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="183249080" data-permission-text="Title is private" data-url="https://github.com/JuliaLang/julia/issues/18965" data-hovercard-type="pull_request" data-hovercard-url="/JuliaLang/julia/pull/18965/hovercard" href="https://github.com/JuliaLang/julia/pull/18965">#18965</a> having <code class="notranslate">Ref</code> to mean <code class="notranslate">RefValue</code> would be more convenient.</p>
<p dir="auto">Also, quoting <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/StefanKarpinski/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/StefanKarpinski">@StefanKarpinski</a></p>
<blockquote>
<p dir="auto">I think that simple concrete names should be used for simple concrete things; programming correctly to an abstraction requires awareness and care, so having a name that reminds you of that is a good thing.</p>
</blockquote>