<p dir="auto">Opening this issue here since I am pretty sure Pkg has not changed anything, maybe this is related to the libgit2 upgrade (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="477439844" data-permission-text="Title is private" data-url="https://github.com/JuliaLang/julia/issues/32806" data-hovercard-type="pull_request" data-hovercard-url="/JuliaLang/julia/pull/32806/hovercard" href="https://github.com/JuliaLang/julia/pull/32806">#32806</a>)?</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ julia13 -e 'using Pkg; Pkg.Registry.update()'
  Updating registry at `~/.julia/registries/General`
  Updating git-repo `https://github.com/JuliaRegistries/General.git`
┌ Warning: Some registries failed to update:
│     — /home/fredrik/.julia/registries/General — failed to fetch from repo
└ @ Pkg.Types ~/julia13/usr/share/julia/stdlib/v1.3/Pkg/src/Types.jl:1189

$ julia12 -e 'using Pkg; Pkg.Registry.update()'
  Updating registry at `~/.julia/registries/General`
  Updating git-repo `https://github.com/JuliaRegistries/General.git`"><pre class="notranslate"><code class="notranslate">$ julia13 -e 'using Pkg; Pkg.Registry.update()'
  Updating registry at `~/.julia/registries/General`
  Updating git-repo `https://github.com/JuliaRegistries/General.git`
┌ Warning: Some registries failed to update:
│     — /home/fredrik/.julia/registries/General — failed to fetch from repo
└ @ Pkg.Types ~/julia13/usr/share/julia/stdlib/v1.3/Pkg/src/Types.jl:1189

$ julia12 -e 'using Pkg; Pkg.Registry.update()'
  Updating registry at `~/.julia/registries/General`
  Updating git-repo `https://github.com/JuliaRegistries/General.git`
</code></pre></div>
<p dir="auto">Hi, I have some thoughts on the edge case return values for the current <code class="notranslate">search</code> API.</p>
<p dir="auto">Currently, <code class="notranslate">search</code> describes a failure to match as follows:</p>
<blockquote>
<p dir="auto">search(string, "substring") = start:end such that string[start:end] == "substring", or 0:-1 if unmatched.</p>
<p dir="auto">search(string, 'c') = index such that string[index] == 'c', or 0 if unmatched.</p>
</blockquote>
<p dir="auto">This means that users of this API must handle the case of <em>unmatching</em> with some non-intuitive check. For example:</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="str = &quot;haystack&quot;
result = search(str, &quot;needle&quot;)
if result == 0:-1 # or result[1] == 0 or first(result) == 0
    # handle case where no result was found
else
    # handle case where result was found
end"><pre class="notranslate">str <span class="pl-k">=</span> <span class="pl-s"><span class="pl-pds">"</span>haystack<span class="pl-pds">"</span></span>
result <span class="pl-k">=</span> <span class="pl-c1">search</span>(str, <span class="pl-s"><span class="pl-pds">"</span>needle<span class="pl-pds">"</span></span>)
<span class="pl-k">if</span> result <span class="pl-k">==</span> <span class="pl-c1">0</span><span class="pl-k">:</span><span class="pl-k">-</span><span class="pl-c1">1</span> <span class="pl-c"><span class="pl-c">#</span> or result[1] == 0 or first(result) == 0</span>
    <span class="pl-c"><span class="pl-c">#</span> handle case where no result was found</span>
<span class="pl-k">else</span>
    <span class="pl-c"><span class="pl-c">#</span> handle case where result was found</span>
<span class="pl-k">end</span></pre></div>
<p dir="auto">It turns out that <code class="notranslate">first(result) == 0</code> is the condition that handles the three cases for when the object to search for (the needle) is either a string, a character, or a vector of characters since the API has two different return types depending on the the needle type.</p>
<p dir="auto">The proposal here is to instead throw some type of exception e.g. <code class="notranslate">UnmatchedException</code>.</p>