Skip to content

Commit 5a7fffc

Browse files
authored
Merge pull request #11470 from jhogberg/john/compiler/fix-unused-record-warning/ERIERL-1345/OTP-20301
erl_lint: Mark records used in record_info/2 as used
2 parents 4641bb3 + f0c2835 commit 5a7fffc

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

lib/stdlib/src/erl_lint.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5282,7 +5282,7 @@ check_record_info_call(_Anno,_Aa,[{atom,Ai,Info},{atom,_An,Name}], St) ->
52825282
true ->
52835283
case St#lint.records of
52845284
#{Name := {_,tuple,_}} ->
5285-
St;
5285+
used_record(Name, St);
52865286
#{} ->
52875287
add_error(Ai, native_record_illegal_record_info, St)
52885288
end;

lib/stdlib/test/erl_lint_SUITE.erl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5697,9 +5697,10 @@ illegal_zip_generator(Config) ->
56975697

56985698
ok.
56995699

5700-
%% GH-9694. Only record_info/2 should be checked for illegal_record_info
57015700
record_info_0(Config) ->
5702-
Ts = [{record_info_0,
5701+
Ts = [%% GH-9694. Only record_info/2 should be checked for
5702+
%% illegal_record_info
5703+
{record_info_0,
57035704
<<"-export([f/0]).
57045705
record_info() -> ok.
57055706
f() -> record_info().
@@ -5712,6 +5713,14 @@ record_info_0(Config) ->
57125713
g() -> record_info(ok).
57135714
">>,
57145715
[],
5716+
[]},
5717+
%% ERIERL-1345: record_info/2 should mark tuple records as used
5718+
{record_info_2,
5719+
<<"-export([h/0]).
5720+
-record(rec,{a,b,c}).
5721+
h() -> record_info(fields, rec).
5722+
">>,
5723+
[],
57155724
[]}
57165725
],
57175726
[] = run(Config, Ts),

0 commit comments

Comments
 (0)