<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="196931" data-post-id="196931">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="josevalim" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/josevalim/120/1787_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  josevalim
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Creator of Elixir</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Thanks for the isolated case. I was able to convert it to Erlang:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">-module(dummy).

-compile([no_auto_import]).

-export([execute/1]).

execute(_x@1) -&gt;
    _a@1 = get_a(_x@1),
    _b@1 = get_b(_x@1),
    erlang:display(_b@1),
    case _a@1 /= _b@1 of
        false -&gt;
            nil;
        true -&gt;
            erlang:display(_b@1),
            ok
    end.

get_a(_x@1) -&gt;
    case _x@1 == &lt;&lt;"A"&gt;&gt; of
        false -&gt;
            2;
        true -&gt;
            3
    end.

get_b(_x@1) -&gt;
    case _x@1 == &lt;&lt;"A"&gt;&gt; of
        false -&gt;
            1;
        true -&gt;
            2
    end.


</code></pre>
<p>And I see the same issue. I will open up a bug report.</p>
<p>Done: <a href="https://bugs.erlang.org/browse/ERL-1440" rel="nofollow">https://bugs.erlang.org/browse/ERL-1440</a></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="196931" data-batch-url="/posts/batch_likers">
                        4
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/weird-incorrect-output-from-a-with-statement/36102/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-196931" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="196931"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-solved cat-solved" title="Marked as solution"></div>
  </section>
</div>
    <div class="postbit" id="196934" data-post-id="196934">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="al2o3cr" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/al2o3cr/120/3457_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  al2o3cr
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>This also <em>stops</em> misbehaving if the code in the <code>false</code> branch of <code>get_a</code> is changed to something optimization-hostile:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">-module(dummy).
-compile([no_auto_import]).
-export([execute/1]).

execute(_x@1) -&gt;
    _a@1 = get_a(_x@1),
    _b@1 = get_b(_x@1),
    erlang:display(_b@1),
    case _a@1 /= _b@1 of
        false -&gt;
            nil;
        true -&gt;
            erlang:display(_b@1),
            ok
    end.
get_a(_x@1) -&gt;
    case _x@1 == &lt;&lt;"A"&gt;&gt; of
        false -&gt;
            erlang:phash2(1,1);
        true -&gt;
            3
    end.
get_b(_x@1) -&gt;
    case _x@1 == &lt;&lt;"A"&gt;&gt; of
        false -&gt;
            1;
        true -&gt;
            2
    end.
</code></pre>
<p>(inspired by the optimization barrier in <code>GenServer</code> and elsewhere)</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="196934" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/weird-incorrect-output-from-a-with-statement/36102/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-196934" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="196934"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #12"></div>
  </section>
</div>
    <div class="postbit" id="196936" data-post-id="196936">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="al2o3cr" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/al2o3cr/120/3457_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  al2o3cr
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Poking around with the example above turns up <em>one</em> difference between code that prints <code>2 1</code> versus <code>2 2</code> (pretty-printed <code>beam_disasm</code>):</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">   {:function, :execute, 1, 2,
    [
      {:label, 1},
      {:line, 1},
      {:func_info, {:atom, :dummy}, {:atom, :execute}, 1},
      {:label, 2},
      {:allocate_zero, 2, 1},
      {:move, {:x, 0}, {:y, 1}},
      {:line, 2},
      {:call, 1, {:dummy, :get_a, 1}},
      {:swap, {:y, 1}, {:x, 0}},
      {:line, 3},
      {:call, 1, {:dummy, :get_b, 1}},
      {:move, {:x, 0}, {:y, 0}},
      {:line, 4},
      {:call_ext, 1, {:extfunc, :erlang, :display, 1}},
      {:test, :is_eq, {:f, 3}, [y: 1, y: 0]},
      {:move, {:atom, nil}, {:x, 0}},
      {:deallocate, 2},
      :return,
      {:label, 3},
      # GOOD VERSION
      {:move, {:y, 0}, {:x, 0}},
      {:trim, 2, 0},
      # BAD VERSION
      {:trim, 2, 0},
      {:move, {:integer, 1}, {:x, 0}},
      # identical from here
      {:line, 5},
      {:call_ext, 1, {:extfunc, :erlang, :display, 1}},
      {:move, {:atom, :ok}, {:x, 0}},
      {:deallocate, 0},
      :return
    ]},
</code></pre>
<p>Something is pulling that <code>1</code> out of the ether…</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="196936" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/weird-incorrect-output-from-a-with-statement/36102/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-196936" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="196936"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>