Skip to content

Commit

Permalink
Merge branch 'bjorn/compiler/ensure_exactly/GH-7467/OTP-18725' into m…
Browse files Browse the repository at this point in the history
…aint

* bjorn/compiler/ensure_exactly/GH-7467/OTP-18725:
  Eliminate consistency failure for non-matching binary pattern
  • Loading branch information
bjorng committed Aug 18, 2023
2 parents ccf8e8e + 064889d commit 0db74ed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/compiler/src/beam_validator.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1720,9 +1720,8 @@ validate_bs_match([I|Is], Ctx, Unit0, Vst0) ->
Vst1 = update_bs_unit(Ctx, Unit, Vst0),
Vst = update_type(fun meet/2, Type, Ctx, Vst1),
validate_bs_match(Is, Ctx, Unit, Vst);
{ensure_exactly,Stride} ->
Vst = advance_bs_context(Ctx, Stride, Vst0),
validate_bs_match(Is, Ctx, Unit0, Vst);
{ensure_exactly,_Stride} ->
validate_bs_match(Is, Ctx, Unit0, Vst0);
{'=:=',nil,Bits,Value} when Bits =< 64, is_integer(Value) ->
validate_bs_match(Is, Ctx, Unit0, Vst0);
{Type0,Live,{literal,Flags},Size,Unit,Dst} when Type0 =:= binary;
Expand Down
5 changes: 5 additions & 0 deletions lib/compiler/test/bs_match_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2722,6 +2722,8 @@ bs_match(_Config) ->

{'EXIT',{{case_clause,_},_}} = catch do_bs_match_gh_6755(id(<<"1000">>)),

{'EXIT',{{badmatch,<<>>},_}} = catch do_bs_match_gh_7467(<<>>),

ok.

do_bs_match_1(_, X) ->
Expand Down Expand Up @@ -2793,6 +2795,9 @@ do_bs_match_gh_6755(B) ->
<<"b">> -> b
end.

do_bs_match_gh_7467(A) ->
do_bs_match_gh_7467(<<_:1/bits>> = A).

%% GH-6348/OTP-18297: Allow aliases for binaries.
-record(ba_foo, {a,b,c}).

Expand Down

0 comments on commit 0db74ed

Please sign in to comment.