Skip to content

Commit 8b83bc0

Browse files
committed
compiler: Test literal binary matching
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.
1 parent 3b7a6ff commit 8b83bc0

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/compiler/test/match_SUITE.erl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
pmatch/1,mixed/1,aliases/1,non_matching_aliases/1,
2525
match_in_call/1,untuplify/1,shortcut_boolean/1,letify_guard/1,
2626
selectify/1,underscore/1,match_map/1,map_vars_used/1,
27-
coverage/1,grab_bag/1]).
27+
coverage/1,grab_bag/1,literal_binary/1]).
2828

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

@@ -40,7 +40,7 @@ groups() ->
4040
match_in_call,untuplify,
4141
shortcut_boolean,letify_guard,selectify,
4242
underscore,match_map,map_vars_used,coverage,
43-
grab_bag]}].
43+
grab_bag,literal_binary]}].
4444

4545

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

577+
%% Regression in 19.0, reported by Alexei Sholik
578+
literal_binary(_Config) ->
579+
3 = literal_binary_match(bar,<<"y">>),
580+
ok.
581+
582+
literal_binary_match(bar, <<"x">>) -> 1;
583+
literal_binary_match(_, <<"x">>) -> 2;
584+
literal_binary_match(_, <<"y">>) -> 3;
585+
literal_binary_match(_, _) -> fail.
577586

578587

579588
id(I) -> I.

0 commit comments

Comments
 (0)