Skip to content

Commit 8501c11

Browse files
committed
Fix test cases with variable bindings in subexpressions
1 parent dc8f568 commit 8501c11

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

lib/stdlib/test/erl_lint_SUITE.erl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,7 +1322,8 @@ unsafe_vars(Config) when is_list(Config) ->
13221322
X.
13231323
">>,
13241324
[warn_unused_vars],
1325-
{warnings,[{{2,38},erl_lint,{unused_var,'Y'}}]}},
1325+
{warnings,[{{2,38},erl_lint,{unused_var,'Y'}},
1326+
{{3,19},erl_lint,{exported_subexpr_var,'X',{'orelse',{2,30}}}}]}},
13261327
{unsafe3,
13271328
<<"t3() ->
13281329
(X = true) andalso (Y = false),
@@ -1337,15 +1338,17 @@ unsafe_vars(Config) when is_list(Config) ->
13371338
X.
13381339
">>,
13391340
[warn_unused_vars],
1340-
[]},
1341+
{warnings,[{{2,46},erl_lint,{exported_subexpr_var,'X',{'andalso',{2,30}}}},
1342+
{{3,19},erl_lint,{exported_subexpr_var,'X',{'andalso',{2,30}}}}]}},
13411343
{unsafe5,
13421344
<<"t5() ->
13431345
Y = 3,
13441346
(X = true) andalso (X = true),
13451347
{X,Y}.
13461348
">>,
13471349
[warn_unused_vars],
1348-
[]},
1350+
{warnings,[{{3,39},erl_lint,{exported_var,'X',{'andalso',{3,30}}}},
1351+
{{4,20},erl_lint,{exported_subexpr_var,'X',{'andalso',{3,30}}}}]}},
13491352
{unsafe6,
13501353
<<"t6() ->
13511354
X = true,

lib/stdlib/test/qlc_SUITE.erl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2371,7 +2371,7 @@ filter(Config) when is_list(Config) ->
23712371

23722372
<<"%% One more of the same kind.
23732373
etsc(fun(E) ->
2374-
QH = qlc:q([{X,Y} || {X,_} <- ets:table(E),
2374+
QH = qlc:q([{X,Y} || {X=Y,_} <- ets:table(E),
23752375
(Y=X) =:= (Y=1+1)]),
23762376
{'EXIT', {{badmatch,2},_}} = (catch qlc:e(QH)),
23772377
false = lookup_keys(QH)
@@ -4889,7 +4889,7 @@ join_merge(Config) when is_list(Config) ->
48894889
R = lists:sort(qlc:e(Q)),
48904890
ets:delete(E1),
48914891
ets:delete(E2),
4892-
true = [{Y,Y} || X <- lists:seq(5, 10), {} =/= (Y = {X,X})] =:= R
4892+
true = [{Y,Y} || X <- lists:seq(5, 10), Y <- [{X,X}]] =:= R
48934893
">>,
48944894

48954895
<<"E1 = create_ets(1, 10),
@@ -4902,7 +4902,7 @@ join_merge(Config) when is_list(Config) ->
49024902
R = lists:sort(qlc:e(Q)),
49034903
ets:delete(E1),
49044904
ets:delete(E2),
4905-
true = [{Y,Y} || X <- lists:seq(5, 10), {} =/= (Y = {X,X})] =:= R
4905+
true = [{Y,Y} || X <- lists:seq(5, 10), Y <- [{X,X}]] =:= R
49064906
">>,
49074907

49084908
<<"E1 = create_ets(1, 10),
@@ -4925,7 +4925,7 @@ join_merge(Config) when is_list(Config) ->
49254925
R = lists:sort(qlc:e(Q)),
49264926
ets:delete(E1),
49274927
ets:delete(E2),
4928-
true = [{Y,Y} || X <- lists:seq(5, 10), {} =/= (Y = {{X,X}})] =:= R
4928+
true = [{Y,Y} || X <- lists:seq(5, 10), Y <- [{{X,X}}]] =:= R
49294929
">>,
49304930

49314931
<<"L1 = [{1,a},{2,a},{1,b},{2,b},{1,c},{2,c}],
@@ -7281,7 +7281,8 @@ manpage(Config) when is_list(Config) ->
72817281
%% ets(3)
72827282
MS = ets:fun2ms(fun({X,Y}) when (X > 1) or (X < 5) -> {Y} end),
72837283
ETs = [
7284-
[<<"true = ets:insert(Tab = ets:new(t, []),[{1,a},{2,b},{3,c},{4,d}]),
7284+
[<<"Tab = ets:new(t, []),
7285+
true = ets:insert(Tab,[{1,a},{2,b},{3,c},{4,d}]),
72857286
MS = ">>, io_lib:format("~w", [MS]), <<",
72867287
QH1 = ets:table(Tab, [{traverse, {select, MS}}]),
72877288

0 commit comments

Comments
 (0)