Skip to content

Commit cccb7a5

Browse files
authored
Merge pull request erlang#11379 from lucioleKi/isabell/compiler/fix/erlangGH-11367/OTP-20262
compiler: Fix crash when key pattern in a map comprehension is bitstring
2 parents 822b2f7 + 7bcfcd4 commit cccb7a5

3 files changed

Lines changed: 37 additions & 4 deletions

File tree

lib/compiler/src/v3_core.erl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4819,8 +4819,10 @@ ibitstr_vars(Segs) ->
48194819

48204820
ibitstr_vars(Segs, Vs) ->
48214821
foldl(fun (#ibitstr{val=V,size=S}, Vs0) ->
4822-
lit_vars(V, lit_vars(S, Vs0))
4823-
end, Vs, Segs).
4822+
lit_vars(V, lit_vars(S, Vs0));
4823+
(#c_bitstr{val=V,size=S}, Vs0) ->
4824+
lit_vars(V, lit_vars(S, Vs0))
4825+
end, Vs, Segs).
48244826

48254827
record_anno(L, #core{dialyzer=Dialyzer}=St) ->
48264828
case erl_anno:record(L) andalso Dialyzer of

lib/compiler/test/compilation_SUITE.erl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
vsn_3/1,
6363
infinite_loop/0,infinite_loop/1,
6464
native_record/1,
65-
use_nifs/1,gh_11352/1]).
65+
use_nifs/1,gh_11352/1,gh_11367/1]).
6666

6767
-include_lib("common_test/include/ct.hrl").
6868
-include_lib("stdlib/include/assert.hrl").
@@ -92,7 +92,7 @@ groups() ->
9292
otp_7202,on_load,on_load_inline,
9393
string_table,otp_8949_a,split_cases,
9494
infinite_loop, native_record,
95-
use_nifs,gh_11352]}].
95+
use_nifs,gh_11352,gh_11367]}].
9696

9797
init_per_suite(Config) ->
9898
test_lib:recompile(?MODULE),
@@ -147,6 +147,7 @@ end_per_group(_GroupName, Config) ->
147147

148148
?comp(use_nifs).
149149
?comp(gh_11352).
150+
?comp(gh_11367).
150151

151152
infinite_loop() -> [{timetrap,{minutes,1}}].
152153
?comp(infinite_loop).
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
%%
2+
%% %CopyrightBegin%
3+
%%
4+
%% SPDX-License-Identifier: Apache-2.0
5+
%%
6+
%% Copyright Ericsson AB 2026. All Rights Reserved.
7+
%%
8+
%% Licensed under the Apache License, Version 2.0 (the "License");
9+
%% you may not use this file except in compliance with the License.
10+
%% You may obtain a copy of the License at
11+
%%
12+
%% http://www.apache.org/licenses/LICENSE-2.0
13+
%%
14+
%% Unless required by applicable law or agreed to in writing, software
15+
%% distributed under the License is distributed on an "AS IS" BASIS,
16+
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
%% See the License for the specific language governing permissions and
18+
%% limitations under the License.
19+
%%
20+
%% %CopyrightEnd%
21+
%%
22+
23+
-module(gh_11367).
24+
-export([?MODULE/0,f/1]).
25+
26+
?MODULE() ->
27+
ok.
28+
29+
f(X) ->
30+
#{X => X || #{<<X/binary>> := _} <- [#{<<X/binary>> => ok}]}.

0 commit comments

Comments
 (0)