Skip to content

Commit

Permalink
Merge branch 'bjorn/compiler/binary-matching/OTP-10567' into maint
Browse files Browse the repository at this point in the history
* bjorn/compiler/binary-matching/OTP-10567:
  Fix compiler crash for binary matching and a complicated guard
  • Loading branch information
bjorng committed Nov 12, 2012
2 parents 135fdb3 + 2da980f commit a7190c2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/compiler/src/v3_codegen.erl
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ bsm_rename_ctx(#l{ke={test,_,_}}=L, _, _, _) -> L;
bsm_rename_ctx(#l{ke={bif,_,_,_}}=L, _, _, _) -> L;
bsm_rename_ctx(#l{ke={gc_bif,_,_,_}}=L, _, _, _) -> L;
bsm_rename_ctx(#l{ke={set,_,_}}=L, _, _, _) -> L;
bsm_rename_ctx(#l{ke={call,_,_,_}}=L, _, _, _) -> L;
bsm_rename_ctx(#l{ke={block,_}}=L, Old, _, false) ->
%% This block is not inside a protected. The match context variable cannot
%% possibly be live inside the block.
Expand Down
17 changes: 17 additions & 0 deletions lib/compiler/test/bs_match_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -800,12 +800,29 @@ matching_and_andalso(Config) when is_list(Config) ->
?line {'EXIT',{function_clause,_}} = (catch matching_and_andalso_1(<<1,2,3>>, -8)),
?line {'EXIT',{function_clause,_}} = (catch matching_and_andalso_1(<<1,2,3>>, blurf)),
?line {'EXIT',{function_clause,_}} = (catch matching_and_andalso_1(<<1,2,3>>, 19)),

{"abc",<<"xyz">>} = matching_and_andalso_2("abc", <<"-xyz">>),
{"abc",<<"">>} = matching_and_andalso_2("abc", <<($a-1)>>),
{"abc",<<"">>} = matching_and_andalso_2("abc", <<($z+1)>>),
{"abc",<<"">>} = matching_and_andalso_2("abc", <<($A-1)>>),
{"abc",<<"">>} = matching_and_andalso_2("abc", <<($Z+1)>>),
error = matching_and_andalso_2([], <<>>),
error = matching_and_andalso_2([], <<$A>>),
error = matching_and_andalso_2([], <<$Z>>),
error = matching_and_andalso_2([], <<$a>>),
error = matching_and_andalso_2([], <<$z>>),
ok.

matching_and_andalso_1(<<Bitmap/binary>>, K)
when is_integer(K) andalso size(Bitmap) >= K andalso 0 < K ->
ok.

matching_and_andalso_2(Datetime, <<H,T/binary>>)
when not ((H >= $a) andalso (H =< $z)) andalso
not ((H >= $A) andalso (H =< $Z)) ->
{Datetime,T};
matching_and_andalso_2(_, _) -> error.

%% Thanks to Tomas Stejskal.
otp_7188(Config) when is_list(Config) ->
MP3 = <<84,65,71,68,117,154,105,232,107,121,0,0,0,0,0,0,0,0,0,0,
Expand Down

0 comments on commit a7190c2

Please sign in to comment.