<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Well, that’s not happening here…<div class=""><br class=""></div><div class=""><div class=""><font face="Menlo" class="">Erlang/OTP 21 [erts-10.0] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">Eshell V10.0 (abort with ^G)</font></div><div class=""><font face="Menlo" class="">1> <<X, Y/binary>> = <<0>>, {X, Y}.</font></div><div class=""><font face="Menlo" class=""><b class="">{0,<<>>}</b></font></div><div class=""><font face="Menlo" class="">2> F = fun(<<X, Y/binary>>) -> {X, Y} end.</font></div><div class=""><font face="Menlo" class="">#Fun<erl_eval.6.127694169></font></div><div class=""><font face="Menlo" class="">3> F(<<0>>).</font></div><div class=""><font face="Menlo" class=""><b class="">{0,<<>>}</b></font></div><div class=""><font face="Menlo" class="">4> {ok, A} = file:read_file("a.erl"), io:format("~s~n", [A]).</font></div><div class=""><font face="Menlo" class="">-module a.</font></div><div class=""><font face="Menlo" class="">-export [f/1].</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">f(<<X, Y/binary>>) -> {X, Y}.</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">ok</font></div><div class=""><font face="Menlo" class="">5> c(a).</font></div><div class=""><font face="Menlo" class="">{ok,a}</font></div><div class=""><font face="Menlo" class="">6> a:f(<<0>>).</font></div><div class=""><font face="Menlo" class=""><b class="">{0,<<>>}</b></font></div><div class=""><font face="Menlo" class="">7></font></div><div class=""><br class="webkit-block-placeholder"></div><div class="">
<div style="color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div style="font-family: "Trebuchet MS"; font-size: 14px; font-weight: normal; white-space: normal;" class=""><span id="docs-internal-guid-e691a4cc-056a-0210-b8b7-ea8d87d888ad" class=""><span style="font-size: 11pt; font-family: Arial; font-weight: 700; font-variant-ligatures: normal; font-variant-position: normal; font-variant-numeric: normal; font-variant-alternates: normal; font-variant-east-asian: normal; vertical-align: baseline; white-space: pre-wrap;" class=""><span style="font-family: "Trebuchet MS"; font-size: 12px; font-weight: normal; white-space: normal;" class="">There must be something else happening with your code.</span></span></span></div><div class=""><span style="font-variant-ligatures: normal; font-variant-position: normal; font-variant-numeric: normal; font-variant-alternates: normal; font-variant-east-asian: normal; vertical-align: baseline;" class=""><br class="Apple-interchange-newline"><hr style="font-family: Arial; font-size: 11pt; font-weight: 700; white-space: pre-wrap;" class=""></span><div style="font-family: "Trebuchet MS"; font-size: 14px; font-weight: normal; white-space: normal;" class=""><b class=""><i class=""><a href="http://about.me/elbrujohalcon" class="">Brujo Benavides</a></i></b></div></div></div><div style="color: rgb(0, 0, 0); font-family: 'Trebuchet MS'; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><b class=""><br class=""></b></div><br class="Apple-interchange-newline">
</div>
<div><br class=""><blockquote type="cite" class=""><div class="">On 3 Aug 2018, at 13:08, 格通 <<a href="mailto:getonga2018@gmail.com" class="">getonga2018@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">I try to fix the mysql-otp for erlang 21, but found a bug like this:<br class=""></div><div class="">```</div><div class=""><div class="">-module(a).</div><div class="">-export([decode_binary/2]).</div><div class="">decode_binary(_, <<Length, Data/binary>>) -></div><div class=""> %% Coded in the same way as DATETIME and TIMESTAMP below, but returned in</div><div class=""> %% a simple triple.</div><div class=""><br class=""></div><div class=""> case {Length, Data} of</div><div class=""> {0, _} -> io:format("~p length:~p, Data:~p, ~n" , [?LINE, Length, Data]),{{0, 0, 0}, Data};</div><div class=""> {4, <<Y:16/little, M, D, Rest/binary>>} -> io:format("~p~n" , [?LINE]),{{Y, M, D}, Rest}</div><div class=""> end.</div></div><div class=""><br class=""></div><div class="">```</div><div class="">A function copy from <a href="https://github.com/mysql-otp/mysql-otp/blob/master/src/mysql_protocol.erl#L789-L795" class="">https://github.com/mysql-otp/mysql-otp/blob/master/src/mysql_protocol.erl#L789-L795</a></div><div class="">My erlang version is 21.0.4, and the pr address is <a href="https://github.com/mysql-otp/mysql-otp/pull/84" class="">https://github.com/mysql-otp/mysql-otp/pull/84</a> .</div><div class="">compile it and run:</div><div class="">```</div><div class="">erlc a.erl</div><div class="">erl</div><div class="">1> a:decode_binary(test, <<0>>).</div><div class="">8 length:0, Data:<<0>>, </div><div class="">{{0,0,0},<<0>>}</div><div class="">```</div><div class="">But in pattern matching:</div><div class="">```</div><div class="">2> <<Length, Data/binary>> = <<0>>.</div><div class=""><<0>></div><div class="">3>Length.</div><div class="">0</div><div class="">4>Data.</div><div class=""><<>></div><div class="">```</div><div class="">It must be a bug in erlang 21 binary matching in function definition.</div></div>
_______________________________________________<br class="">erlang-questions mailing list<br class=""><a href="mailto:erlang-questions@erlang.org" class="">erlang-questions@erlang.org</a><br class="">http://erlang.org/mailman/listinfo/erlang-questions<br class=""></div></blockquote></div><br class=""></div></body></html>