Describe the bug
Lazy loading of modules does not work for native records.
An exception {badrecord,{Module,Name}} is generated when a Native Record from another module is declared in the code but that module has not yet been loaded.
To Reproduce
- write application with two modules:
-module(db).
-export_record([product]).
-record #product{id}.
-module(helper).
-compile(export_all).
y() -> #db:product{id=2232}.
- add a call
helper:y() into application:start/2 or call it manually via the attached console:
$ rebar3 shell
Erlang/OTP 29 [erts-17.0.3] [source] [64-bit] [smp:18:18] [ds:18:18:10] [async-threads:1] [jit]
Eshell V17.0.3 (press Ctrl+G to abort, type help(). for help)
1> helper:y().
** exception error: {badrecord,{db,product}}
in function helper:y/0 (src/helper.erl:8)
2> code:load_file(db).
{module,db}
3> helper:y().
#db:product{id = 2232}
Expected behavior
When attempting to access a native record from another module, the target module will be preloaded and the Native Record is created without errors.
Affected versions
❯ cat .tool-versions
erlang 29.0.3
rebar 3.27.0
Additional context
rebar3 and erlc exhibit the same behavior
Describe the bug
Lazy loading of modules does not work for native records.
An exception
{badrecord,{Module,Name}}is generated when a Native Record from another module is declared in the code but that module has not yet been loaded.To Reproduce
helper:y()intoapplication:start/2or call it manually via the attached console:Expected behavior
When attempting to access a native record from another module, the target module will be preloaded and the Native Record is created without errors.
Affected versions
Additional context
rebar3anderlcexhibit the same behavior