diff options
author | Erlang/OTP <[email protected]> | 2018-06-29 14:30:24 +0200 |
---|---|---|
committer | Erlang/OTP <[email protected]> | 2018-06-29 14:30:24 +0200 |
commit | b2aa37d72997df921e935380a77b0e0226f33401 (patch) | |
tree | 38ce1ca11843379749d1dc0569e6969ece3b3004 /lib/compiler/test | |
parent | a7346cb8e104305a8bd49062e76a0496bf39cfe9 (diff) | |
parent | 81ce942d77826dd7219f1226866ffb2fa71c1d28 (diff) | |
download | otp-b2aa37d72997df921e935380a77b0e0226f33401.tar.gz otp-b2aa37d72997df921e935380a77b0e0226f33401.tar.bz2 otp-b2aa37d72997df921e935380a77b0e0226f33401.zip |
Merge branch 'bjorn/compiler/fix-skipped-matching/ERL-655/OTP-15156' into maint-21
* bjorn/compiler/fix-skipped-matching/ERL-655/OTP-15156:
beam_type: Fix unsafe optimization
Diffstat (limited to 'lib/compiler/test')
-rw-r--r-- | lib/compiler/test/beam_type_SUITE.erl | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/lib/compiler/test/beam_type_SUITE.erl b/lib/compiler/test/beam_type_SUITE.erl index 499b9b41df..1355f9f862 100644 --- a/lib/compiler/test/beam_type_SUITE.erl +++ b/lib/compiler/test/beam_type_SUITE.erl @@ -23,7 +23,7 @@ init_per_group/2,end_per_group/2, integers/1,coverage/1,booleans/1,setelement/1,cons/1, tuple/1,record_float/1,binary_float/1,float_compare/1, - arity_checks/1,elixir_binaries/1]). + arity_checks/1,elixir_binaries/1,find_best/1]). suite() -> [{ct_hooks,[ts_install_cth]}]. @@ -43,7 +43,8 @@ groups() -> binary_float, float_compare, arity_checks, - elixir_binaries + elixir_binaries, + find_best ]}]. init_per_suite(Config) -> @@ -292,6 +293,33 @@ elixir_bitstring_3(Bar) when is_bitstring(Bar) -> list_to_bitstring(Rewrite) end/bitstring>>. +find_best(_Config) -> + ok = find_best([a], nil), + ok = find_best([<<"a">>], nil), + {error,_} = find_best([], nil), + ok. + +%% Failed because beam_type assumed that the operand +%% for bs_context_binary must be a binary. Not true! +find_best([a|Tail], Best) -> + find_best(Tail, + case Best of + X when X =:= nil orelse X =:= false -> a; + X -> X + end); +find_best([<<"a">>|Tail], Best) -> + find_best(Tail, + case Best of + X when X =:= nil orelse X =:= false -> <<"a">>; + X -> X + end); +find_best([], a) -> + ok; +find_best([], <<"a">>) -> + ok; +find_best([], nil) -> + {error,<<"should not get here">>}. + id(I) -> I. |