Skip to content

Commit 64edbc0

Browse files
committed
compiler: Suppress incorrect useless_building warning
Fix #11472
1 parent 322d2f9 commit 64edbc0

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

lib/compiler/src/sys_core_fold.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2901,7 +2901,7 @@ void() -> #c_literal{val=ok}.
29012901
descend(_Core, #sub{top=false}=Sub) ->
29022902
Sub;
29032903
descend(Core, #sub{top=true}=Sub) ->
2904-
case should_suppress_warning(Core) of
2904+
case should_suppress_warning(Core) andalso not is_result_unwanted(Core) of
29052905
true ->
29062906
%% In a list comprehension being ignored such as:
29072907
%%

lib/stdlib/test/erl_lint_SUITE.erl

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@
9696
record_info_0/1,
9797
coverage/1,
9898
native_records/1,
99-
invalid_attribute/1]).
99+
invalid_attribute/1,
100+
gh_11472/1]).
100101

101102
suite() ->
102103
[{ct_hooks,[ts_install_cth]},
@@ -139,7 +140,8 @@ all() ->
139140
record_info_0,
140141
coverage,
141142
native_records,
142-
invalid_attribute].
143+
invalid_attribute,
144+
gh_11472].
143145

144146
groups() ->
145147
[{unused_vars_warn, [],
@@ -6074,6 +6076,25 @@ invalid_attribute(Config) ->
60746076

60756077
ok.
60766078

6079+
gh_11472(Config) ->
6080+
Ts = [{nowarn,
6081+
<<"-export([f/1]).
6082+
f(Acc) ->
6083+
X = 0,
6084+
{Y} =
6085+
begin
6086+
_Fresh1 = {[X | Acc]},
6087+
_Fresh1
6088+
end,
6089+
Y.
6090+
">>,
6091+
{[]},
6092+
[]}
6093+
],
6094+
[] = run(Config,Ts),
6095+
6096+
ok.
6097+
60776098
%%%
60786099
%%% Common utilities.
60796100
%%%

0 commit comments

Comments
 (0)