<div dir="ltr"><div>I try to fix the mysql-otp  for erlang 21, but found a bug  like this:<br></div><div>```</div><div><div>-module(a).</div><div>-export([decode_binary/2]).</div><div>decode_binary(_, <<Length, Data/binary>>) -></div><div>    %% Coded in the same way as DATETIME and TIMESTAMP below, but returned in</div><div>    %% a simple triple.</div><div><br></div><div>    case {Length, Data} of</div><div>        {0, _} -> io:format("~p length:~p, Data:~p, ~n" , [?LINE, Length, Data]),{{0, 0, 0}, Data};</div><div>        {4, <<Y:16/little, M, D, Rest/binary>>} -> io:format("~p~n" , [?LINE]),{{Y, M, D}, Rest}</div><div>    end.</div></div><div><br></div><div>```</div><div>A function copy from <a href="https://github.com/mysql-otp/mysql-otp/blob/master/src/mysql_protocol.erl#L789-L795">https://github.com/mysql-otp/mysql-otp/blob/master/src/mysql_protocol.erl#L789-L795</a></div><div>My erlang version is 21.0.4, and the pr address is  <a href="https://github.com/mysql-otp/mysql-otp/pull/84">https://github.com/mysql-otp/mysql-otp/pull/84</a> .</div><div>compile it and run:</div><div>```</div><div>erlc a.erl</div><div>erl</div><div>1> a:decode_binary(test, <<0>>).</div><div>8 length:0, Data:<<0>>, </div><div>{{0,0,0},<<0>>}</div><div>```</div><div>But in pattern matching:</div><div>```</div><div>2> <<Length, Data/binary>> = <<0>>.</div><div><<0>></div><div>3>Length.</div><div>0</div><div>4>Data.</div><div><<>></div><div>```</div><div>It must be a bug in erlang 21 binary matching in function definition.</div></div>