<p dir="auto">I'm not sure if this is a duplicate of the other let block issues, but I came across this:</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="let
    global foo

    bar(x::Float64) = x+1
    bar(x::Float32) = x+2

    foo(x) = bar(x)
end"><pre class="notranslate"><span class="pl-k">let</span>
    <span class="pl-k">global</span> foo

    <span class="pl-en">bar</span>(x<span class="pl-k">::</span><span class="pl-c1">Float64</span>) <span class="pl-k">=</span> x<span class="pl-k">+</span><span class="pl-c1">1</span>
    <span class="pl-en">bar</span>(x<span class="pl-k">::</span><span class="pl-c1">Float32</span>) <span class="pl-k">=</span> x<span class="pl-k">+</span><span class="pl-c1">2</span>

    <span class="pl-en">foo</span>(x) <span class="pl-k">=</span> <span class="pl-c1">bar</span>(x)
<span class="pl-k">end</span></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="julia&gt; @code_warntype foo(1.0)
Variables:
  #self#::#foo
  x::Float64

Body:
  begin 
      return ((Core.getfield)($(QuoteNode(Core.Box(bar))),:contents)::Any)(x::Float64)::Any
  end::Any"><pre class="notranslate"><code class="notranslate">julia&gt; @code_warntype foo(1.0)
Variables:
  #self#::#foo
  x::Float64

Body:
  begin 
      return ((Core.getfield)($(QuoteNode(Core.Box(bar))),:contents)::Any)(x::Float64)::Any
  end::Any
</code></pre></div>
<p dir="auto">This problem goes away if I get rid of the 2nd method for <code class="notranslate">bar</code>.</p>
<p dir="auto"><code class="notranslate">@testset</code> internally creates a try/catch block to run the tests in, so the tests are run in a local scope.  However, since the syntax is <code class="notranslate">@testset "..." begin ... end</code>, it is natural to assume the code is run in a <code class="notranslate">begin</code> block, which is globally scoped.</p>
<p dir="auto">This can lead to confusing behavior where functions defined within a testset capture variables defined outside the function, since we are in a local scope, but users may not realize this.  I suggest we at least document this local scoping behavior of <code class="notranslate">@testset</code>, or perhaps change the syntax to <code class="notranslate">@testset "..." let ... end</code> to make it more apparent that this introduces a local scope.</p>