diff options
author | Erlang/OTP <otp@erlang.org> | 2023-04-25 17:08:52 +0200 |
---|---|---|
committer | Erlang/OTP <otp@erlang.org> | 2023-04-25 17:08:52 +0200 |
commit | ec59a080681865a8a32003ec527b6802e8aefdc5 (patch) | |
tree | 3d6fa69af031753c0190f39c9cdab5f14152ad9f /lib | |
parent | e597996dded611ed8b07a29e666599818607fc12 (diff) | |
parent | c62f3fabe2ee9ca610f1fc9605181b06f820c31c (diff) | |
download | erlang-ec59a080681865a8a32003ec527b6802e8aefdc5.tar.gz |
Merge branch 'john/erts/fix-hd-tl-loader-transformations/GH-7024/OTP-18519' into maint-25
* john/erts/fix-hd-tl-loader-transformations/GH-7024/OTP-18519:
jit: Fix hd/1 and tl/1 BIF specialization
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compiler/test/bif_SUITE.erl | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/lib/compiler/test/bif_SUITE.erl b/lib/compiler/test/bif_SUITE.erl index 8480569507..34bf54a871 100644 --- a/lib/compiler/test/bif_SUITE.erl +++ b/lib/compiler/test/bif_SUITE.erl @@ -24,7 +24,8 @@ -export([all/0,suite/0,groups/0,init_per_suite/1,end_per_suite/1, init_per_group/2,end_per_group/2, beam_validator/1,trunc_and_friends/1,cover_safe_and_pure_bifs/1, - cover_trim/1]). + cover_trim/1, + head_tail/1]). suite() -> [{ct_hooks,[ts_install_cth]}]. @@ -37,7 +38,8 @@ groups() -> [beam_validator, trunc_and_friends, cover_safe_and_pure_bifs, - cover_trim + cover_trim, + head_tail ]}]. init_per_suite(Config) -> @@ -167,6 +169,28 @@ cover_trim_3(Header, N)-> false end. +%% GH-7024: The loader transformations for hd/1 and tl/1 were incorrect and +%% failed when certain optimizations were turned off. +head_tail(_Config) -> + {1, ok} = head_case(), + {1, ok} = tail_case(), + + 1 = hd(id([1])), + [] = tl(id([1])), + + ok. + +head_case() -> + case 1 of + X when hd(X) -> blurf; + X -> {X, ok} + end. + +tail_case() -> + case 1 of + X when tl(X) -> blurf; + X -> {X, ok} + end. id(I) -> I. |