Skip to content

Commit df7296a

Browse files
committed
compiler: Fix nomatch crash with map comprehension in v3_core
Fix #11352.
1 parent 9e43a43 commit df7296a

3 files changed

Lines changed: 40 additions & 2 deletions

File tree

lib/compiler/src/v3_core.erl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2788,6 +2788,7 @@ add_bound_vars({mc, Pairs, BoundVars}, AccPat) ->
27882788
%% add_pre_bound_vars(Ctx, Pre) -> Ctx.
27892789
%% Add variables bound in pre-expressions (from filters) to mc context.
27902790
add_pre_bound_vars({lc, E}, _Pre) -> {lc, E};
2791+
add_pre_bound_vars({mc, Pairs, nomatch}, _Pre) -> {mc, Pairs, nomatch};
27912792
add_pre_bound_vars({mc, Pairs, BoundVars}, Pre) ->
27922793
NewVars = ordsets:union([pre_expr_vars(E) || E <- Pre]),
27932794
{mc, Pairs, ordsets:union(NewVars, BoundVars)}.

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]).
65+
use_nifs/1,gh_11352/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]}].
95+
use_nifs,gh_11352]}].
9696

9797
init_per_suite(Config) ->
9898
test_lib:recompile(?MODULE),
@@ -146,6 +146,7 @@ end_per_group(_GroupName, Config) ->
146146
?comp(native_record).
147147

148148
?comp(use_nifs).
149+
?comp(gh_11352).
149150

150151
infinite_loop() -> [{timetrap,{minutes,1}}].
151152
?comp(infinite_loop).
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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_11352).
24+
-export([?MODULE/0]).
25+
26+
?MODULE() ->
27+
ok.
28+
29+
f6() ->
30+
#{
31+
ok => ok
32+
|| <<>> = [] := _ <- ok,
33+
begin
34+
_ = ok
35+
end
36+
}.

0 commit comments

Comments
 (0)