<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="function f()
    for i in [1,2,3,4]

        println(&quot;i = $i&quot;)
        try
            [1,2][i]
        catch e
            println(&quot;catch!&quot;)
            if (rand() &gt; 0.5)
                break
            else
                return
            end
        finally
            println(&quot;finally!&quot;)
        end

        println(&quot;&quot;)
    end
end"><pre class="notranslate"><span class="pl-k">function</span> <span class="pl-en">f</span>()
    <span class="pl-k">for</span> i <span class="pl-k">in</span> [<span class="pl-c1">1</span>,<span class="pl-c1">2</span>,<span class="pl-c1">3</span>,<span class="pl-c1">4</span>]

        <span class="pl-c1">println</span>(<span class="pl-s"><span class="pl-pds">"</span>i = <span class="pl-v">$i</span><span class="pl-pds">"</span></span>)
        <span class="pl-k">try</span>
            [<span class="pl-c1">1</span>,<span class="pl-c1">2</span>][i]
        <span class="pl-k">catch</span> e
            <span class="pl-c1">println</span>(<span class="pl-s"><span class="pl-pds">"</span>catch!<span class="pl-pds">"</span></span>)
            <span class="pl-k">if</span> (<span class="pl-c1">rand</span>() <span class="pl-k">&gt;</span> <span class="pl-c1">0.5</span>)
                <span class="pl-k">break</span>
            <span class="pl-k">else</span>
                <span class="pl-k">return</span>
            <span class="pl-k">end</span>
        <span class="pl-k">finally</span>
            <span class="pl-c1">println</span>(<span class="pl-s"><span class="pl-pds">"</span>finally!<span class="pl-pds">"</span></span>)
        <span class="pl-k">end</span>

        <span class="pl-c1">println</span>(<span class="pl-s"><span class="pl-pds">"</span><span class="pl-pds">"</span></span>)
    <span class="pl-k">end</span>
<span class="pl-k">end</span></pre></div>
<p dir="auto"><code class="notranslate">return</code> from the catch block results in the <code class="notranslate">finally</code> block being executed.<br>
However, <code class="notranslate">break</code> from the catch block causes the <code class="notranslate">finally</code> block to be skipped.</p>
<p dir="auto">I expect the below code to print "finally", but nothing gets printed. It seems as though the break statement results in the finally block never executing.</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="for i=1:10
  try
    break
  finally
    println(&quot;finally&quot;)
  end
end"><pre class="notranslate"><span class="pl-k">for</span> i<span class="pl-k">=</span><span class="pl-c1">1</span><span class="pl-k">:</span><span class="pl-c1">10</span>
  <span class="pl-k">try</span>
    <span class="pl-k">break</span>
  <span class="pl-k">finally</span>
    <span class="pl-c1">println</span>(<span class="pl-s"><span class="pl-pds">"</span>finally<span class="pl-pds">"</span></span>)
  <span class="pl-k">end</span>
<span class="pl-k">end</span></pre></div>
<p dir="auto">versioninfo():</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Julia Version 0.4.0-dev+6971
Commit c7809f8 (2015-08-25 22:51 UTC)
Platform Info:
  System: Linux (x86_64-amazon-linux)
  CPU: Intel(R) Xeon(R) CPU E5-2670 v2 @ 2.50GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Sandybridge)
  LAPACK: libopenblas
  LIBM: libopenlibm
  LLVM: libLLVM-3.3"><pre class="notranslate"><code class="notranslate">Julia Version 0.4.0-dev+6971
Commit c7809f8 (2015-08-25 22:51 UTC)
Platform Info:
  System: Linux (x86_64-amazon-linux)
  CPU: Intel(R) Xeon(R) CPU E5-2670 v2 @ 2.50GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Sandybridge)
  LAPACK: libopenblas
  LIBM: libopenlibm
  LLVM: libLLVM-3.3
</code></pre></div>