Skip to content

save_module/1 shell function ignore records from rr/1 . #9816

Closed
@crownedgrouse

Description

@crownedgrouse

Describe the bug
Record definitions are missing in module generated by save_module/1 function in shell when using rr/1, while not missing when using new OTP26 way to define record in shell (erlang code syntax).

To Reproduce

$> cat /tmp/record.hrl
-record(test, {a, b}).
1> rr("/tmp/record.hrl").
[test]
2> save_module("/tmp/mymodule.erl").
{ok,mymodule}
3> c(mymodule, [debug_info]).
Recompiling /tmp/mymodule.erl
{ok,mymodule}
4> beam_lib:chunks(mymodule, [abstract_code]).
{ok,{mymodule,[{abstract_code,{raw_abstract_v1,[{attribute,{1,
                                                            1},
                                                           file,
                                                           {"/tmp/mymodule.erl",1}},
                                                {attribute,{1,2},module,mymodule},
                                                {attribute,{3,2},export,[]},
                                                {eof,{5,1}}]}}]}}
5> -record(test, {a, b}).
ok
6> save_module("/tmp/mymodule.erl").
File exists, do you want to overwrite it? (y/N)
y
/tmp/mymodule.erl:5:2: Warning: record test is unused
%    5| -record(test,{a, b}).
%     |  ^

{ok,mymodule}
7> c(mymodule, [debug_info]).
Recompiling /tmp/mymodule.erl
/tmp/mymodule.erl:5:2: Warning: record test is unused
%    5| -record(test,{a, b}).
%     |  ^

{ok,mymodule}
8> beam_lib:chunks(mymodule, [abstract_code]).
{ok,{mymodule,[{abstract_code,{raw_abstract_v1,[{attribute,{1,
                                                            1},
                                                           file,
                                                           {"/tmp/mymodule.erl",1}},
                                                {attribute,{1,2},module,mymodule},
                                                {attribute,{3,2},export,[]},
                                                {attribute,{5,2},
                                                           record,
                                                           {test,[{record_field,{5,15},{atom,{5,15},a}},
                                                                  {record_field,{5,18},{atom,{5,18},b}}]}},
                                                {eof,{6,1}}]}}]}}

Expected behavior
Behavior should be the same between loading record definition with legacy rr/1 or new way of typing record definition since OTP26.

Affected versions
OTP 27 at least.

Metadata

Metadata

Assignees

Labels

bugIssue is reported as a bugteam:VMAssigned to OTP team VM

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions