W0067 - Missing ms_transform include for ets:fun2ms/1
Warning
-module(foo).
select_all() ->
ets:fun2ms(fun({K, V}) -> {K, V} end).
%% ^^^^^^^^^^ 💡 warning: W0067: Call to `ets:fun2ms/1` requires `-include_lib("stdlib/include/ms_transform.hrl").`
Explanation
The ets:fun2ms/1 function is a hook for a parse transform that converts fun expressions into match specifications at compile time. It requires the ms_transform header to be included in the module for the parse transform to be applied.
Without the include, the fun expression will not be converted into a match specification and will instead fail at runtime with an error like:
{badarg,{?MODULE,fun2ms,
[function,called,with,real,'fun',
should,be,transformed,with,
parse_transform,'or',called,with,
a,'fun',generated,in,the,
shell]}}
Fix
Add the following include to the module:
-include_lib("stdlib/include/ms_transform.hrl").
The quick fix offered by ELP will add this include automatically, placing it above the first existing include directive, or above the first function or type definition if there are no includes.