File 1762-Fix-test-cases-with-variable-bindings-in-subexpressi.patch of Package erlang
From 9344da703e8cdcc2e821136e796d7ff2db8450c1 Mon Sep 17 00:00:00 2001
From: Richard Carlsson <carlsson.richard@gmail.com>
Date: Sat, 22 Nov 2025 12:18:17 +0100
Subject: [PATCH 2/2] Fix test cases with variable bindings in subexpressions
---
lib/stdlib/test/erl_lint_SUITE.erl | 15 +++++++++------
lib/stdlib/test/qlc_SUITE.erl | 12 ++++++------
2 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/lib/stdlib/test/erl_lint_SUITE.erl b/lib/stdlib/test/erl_lint_SUITE.erl
index 72dd8a9dfe..b3612e9af7 100644
--- a/lib/stdlib/test/erl_lint_SUITE.erl
+++ b/lib/stdlib/test/erl_lint_SUITE.erl
@@ -1317,12 +1317,13 @@ unsafe_vars(Config) when is_list(Config) ->
{error,[{{3,19},erl_lint,{unsafe_var,'Y',{'orelse',{2,29}}}}],
[{{2,19},erl_lint,{unused_var,'X'}}]}},
{unsafe2,
- <<"-compile(nowarn_export_var_subexpr). t2() ->
+ <<"t2() ->
(X = true) orelse (Y = false),
X.
">>,
[warn_unused_vars],
- {warnings,[{{2,38},erl_lint,{unused_var,'Y'}}]}},
+ {warnings,[{{2,38},erl_lint,{unused_var,'Y'}},
+ {{3,19},erl_lint,{export_var_subexpr,'X',{'orelse',{2,30}}}}]}},
{unsafe3,
<<"t3() ->
(X = true) andalso (Y = false),
@@ -1332,20 +1333,22 @@ unsafe_vars(Config) when is_list(Config) ->
{error,[{{3,19},erl_lint,{unsafe_var,'Y',{'andalso',{2,30}}}}],
[{{2,20},erl_lint,{unused_var,'X'}}]}},
{unsafe4,
- <<"-compile(nowarn_export_var_subexpr). t4() ->
+ <<"t4() ->
(X = true) andalso (true = X),
X.
">>,
[warn_unused_vars],
- []},
+ {warnings,[{{2,46},erl_lint,{export_var_subexpr,'X',{'andalso',{2,30}}}},
+ {{3,19},erl_lint,{export_var_subexpr,'X',{'andalso',{2,30}}}}]}},
{unsafe5,
- <<"-compile(nowarn_export_var_subexpr). t5() ->
+ <<"t5() ->
Y = 3,
(X = true) andalso (X = true),
{X,Y}.
">>,
[warn_unused_vars],
- []},
+ {warnings,[{{3,39},erl_lint,{export_var_subexpr,'X',{'andalso',{3,30}}}},
+ {{4,20},erl_lint,{export_var_subexpr,'X',{'andalso',{3,30}}}}]}},
{unsafe6,
<<"t6() ->
X = true,
diff --git a/lib/stdlib/test/qlc_SUITE.erl b/lib/stdlib/test/qlc_SUITE.erl
index c94a1c03a6..55e8426775 100644
--- a/lib/stdlib/test/qlc_SUITE.erl
+++ b/lib/stdlib/test/qlc_SUITE.erl
@@ -2371,7 +2371,7 @@ filter(Config) when is_list(Config) ->
<<"%% One more of the same kind.
etsc(fun(E) ->
- QH = qlc:q([{X,Y} || {X,_} <- ets:table(E),
+ QH = qlc:q([{X,Y} || {X=Y,_} <- ets:table(E),
(Y=X) =:= (Y=1+1)]),
{'EXIT', {{badmatch,2},_}} = (catch qlc:e(QH)),
false = lookup_keys(QH)
@@ -4889,7 +4889,7 @@ join_merge(Config) when is_list(Config) ->
R = lists:sort(qlc:e(Q)),
ets:delete(E1),
ets:delete(E2),
- true = [{Y,Y} || X <- lists:seq(5, 10), {} =/= (Y = {X,X})] =:= R
+ true = [{Y,Y} || X <- lists:seq(5, 10), Y <- [{X,X}]] =:= R
">>,
<<"E1 = create_ets(1, 10),
@@ -4902,7 +4902,7 @@ join_merge(Config) when is_list(Config) ->
R = lists:sort(qlc:e(Q)),
ets:delete(E1),
ets:delete(E2),
- true = [{Y,Y} || X <- lists:seq(5, 10), {} =/= (Y = {X,X})] =:= R
+ true = [{Y,Y} || X <- lists:seq(5, 10), Y <- [{X,X}]] =:= R
">>,
<<"E1 = create_ets(1, 10),
@@ -4925,7 +4925,7 @@ join_merge(Config) when is_list(Config) ->
R = lists:sort(qlc:e(Q)),
ets:delete(E1),
ets:delete(E2),
- true = [{Y,Y} || X <- lists:seq(5, 10), {} =/= (Y = {{X,X}})] =:= R
+ true = [{Y,Y} || X <- lists:seq(5, 10), Y <- [{{X,X}}]] =:= R
">>,
<<"L1 = [{1,a},{2,a},{1,b},{2,b},{1,c},{2,c}],
@@ -7281,7 +7281,8 @@ manpage(Config) when is_list(Config) ->
%% ets(3)
MS = ets:fun2ms(fun({X,Y}) when (X > 1) or (X < 5) -> {Y} end),
ETs = [
- [<<"true = ets:insert(Tab = ets:new(t, []),[{1,a},{2,b},{3,c},{4,d}]),
+ [<<"Tab = ets:new(t, []),
+ true = ets:insert(Tab,[{1,a},{2,b},{3,c},{4,d}]),
MS = ">>, io_lib:format("~w", [MS]), <<",
QH1 = ets:table(Tab, [{traverse, {select, MS}}]),
@@ -8004,7 +8005,6 @@ compile(Config, Tests, Fun) ->
compile_file(Config, Test0, Opts0) ->
{File, Mod} = compile_file_mod(Config),
Test = list_to_binary(["-module(", atom_to_list(Mod), "). "
- "-compile(nowarn_export_var_subexpr). "
"-import(qlc_SUITE, [i/1,i/2,format_info/2]). "
"-import(qlc_SUITE, [etsc/2, etsc/3]). "
"-import(qlc_SUITE, [create_ets/2]). "
--
2.51.0