Skip to content

Commit

Permalink
compiler: Test literal binary matching
Browse files Browse the repository at this point in the history
The following regression was introduced in 19.0:

    foo(bar, <<"x">>) -> 1;
    foo(_, <<"x">>) -> 2;
    foo(_, <<"y">>) -> 3;
    foo(_, _) -> fail.

The call foo(bar,<<"y">>) would errorneous return 'fail' instead of 3.

A testcase in match_SUITE has been added to verify this.
  • Loading branch information
psyeugenic committed Jul 12, 2016
1 parent 3b7a6ff commit 8b83bc0
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/compiler/test/match_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
pmatch/1,mixed/1,aliases/1,non_matching_aliases/1,
match_in_call/1,untuplify/1,shortcut_boolean/1,letify_guard/1,
selectify/1,underscore/1,match_map/1,map_vars_used/1,
coverage/1,grab_bag/1]).
coverage/1,grab_bag/1,literal_binary/1]).

-include_lib("common_test/include/ct.hrl").

Expand All @@ -40,7 +40,7 @@ groups() ->
match_in_call,untuplify,
shortcut_boolean,letify_guard,selectify,
underscore,match_map,map_vars_used,coverage,
grab_bag]}].
grab_bag,literal_binary]}].


init_per_suite(Config) ->
Expand Down Expand Up @@ -574,6 +574,15 @@ grab_bag_remove_failure([{stretch,_,Mi}=Stretch | Specs], Unit, _MaxFailure) ->
ok
end.

%% Regression in 19.0, reported by Alexei Sholik
literal_binary(_Config) ->
3 = literal_binary_match(bar,<<"y">>),
ok.

literal_binary_match(bar, <<"x">>) -> 1;
literal_binary_match(_, <<"x">>) -> 2;
literal_binary_match(_, <<"y">>) -> 3;
literal_binary_match(_, _) -> fail.


id(I) -> I.

0 comments on commit 8b83bc0

Please sign in to comment.