Skip to content

Commit

Permalink
Merge branch 'maint'
Browse files Browse the repository at this point in the history
* maint:
  Eliminate crash in dialyzer_typesig
  • Loading branch information
bjorng committed Nov 21, 2022
2 parents 0800de8 + 963a621 commit 058e356
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/dialyzer/src/dialyzer_typesig.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,8 @@ bitstr_constr(SizeType, UnitVal, ConstructOrMatch) ->
end,
fun(Map) ->
TmpSizeType = lookup_type(SizeType, Map),
case t_is_subtype(TmpSizeType, t_non_neg_integer()) of
case t_is_integer(TmpSizeType) andalso
t_is_subtype(TmpSizeType, t_non_neg_integer()) of
true ->
case t_number_vals(TmpSizeType) of
[OneSize] -> t_bitstr(Unit, OneSize * UnitVal);
Expand All @@ -1062,7 +1063,8 @@ bitstr_constr(SizeType, UnitVal, ConstructOrMatch) ->
bitstr_val_constr(SizeType, UnitVal, Flags) ->
fun(Map) ->
TmpSizeType = lookup_type(SizeType, Map),
case t_is_subtype(TmpSizeType, t_non_neg_integer()) of
case t_is_integer(TmpSizeType) andalso
t_is_subtype(TmpSizeType, t_non_neg_integer()) of
true ->
case erl_types:number_max(TmpSizeType) of
N when is_integer(N), N < 128 -> %% Avoid illegal arithmetic
Expand Down
1 change: 1 addition & 0 deletions lib/dialyzer/test/small_SUITE_data/results/bs_fail_constr
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ bs_fail_constr.erl:18:1: Function bad_size_1/1 has no local return
bs_fail_constr.erl:18:1: The pattern <<X:[]>> can never match the type any()
bs_fail_constr.erl:21:1: Function bad_size_2/1 has no local return
bs_fail_constr.erl:24:9: The pattern <<X:Size>> can never match the type any()
bs_fail_constr.erl:29:1: Function bad_size_3/1 has no local return
bs_fail_constr.erl:5:1: Function w1/1 has no local return
bs_fail_constr.erl:6:5: Binary construction will fail since the value field V in segment V has type float()
bs_fail_constr.erl:8:1: Function w2/1 has no local return
Expand Down
7 changes: 6 additions & 1 deletion lib/dialyzer/test/small_SUITE_data/src/bs_fail_constr.erl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-module(bs_fail_constr).

-export([w1/1, w2/1, w3/1, w4/1, bad_size_1/1, bad_size_2/1]).
-export([w1/1, w2/1, w3/1, w4/1, bad_size_1/1, bad_size_2/1, bad_size_3/1]).

w1(V) when is_float(V) ->
<<V/integer>>.
Expand All @@ -24,3 +24,8 @@ bad_size_2(Bin) ->
<<X:Size>> ->
ok
end.

%% GH-6473
bad_size_3(X) when X; <<X:X>> ->
bad_size_3(X),
X.

0 comments on commit 058e356

Please sign in to comment.