Skip to content

Instantly share code, notes, and snippets.

@tapickell
Forked from ConnorRigby/otp-21-bug.exs
Created August 3, 2018 17:42
Show Gist options
  • Save tapickell/7e32bd7e543d6d2449ce30fbbc984645 to your computer and use it in GitHub Desktop.
Save tapickell/7e32bd7e543d6d2449ce30fbbc984645 to your computer and use it in GitHub Desktop.
defmodule A do
def err(_, <<length, data :: binary>>) do
case {length, data} do
{0, _} -> data
{4, <<rest :: binary>>} -> rest
end
end
end
<<0>> = A.err(0, <<0>>)
<<2>> = A.err(0, <<4, 2>>)
defmodule B do
def err(_, <<length, data :: binary>>) do
case {length, data} do
{0, <<rest :: binary>>} -> rest
{4, _} -> data
end
end
end
<<1>> = B.err(0, <<0, 1>>)
<<2>> = B.err(0, <<4, 2>>)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment