W0049 - Prefer [{version, 2}] when constructing a set
Error
-module(main).
foo() -> sets:new().
%% ^^^^^^^^^^ 💡 warning: Prefer `[{version, 2}]` when constructing a set.
Explanation
Erlang/OTP 24.0 introduced a new internal representation for sets which is more
performant. Developers can use this new representation by passing the
{version, 2} flag to new/1 and from_list/2, such as
sets:new([{version, 2}]).
Note: This diagnostic is only active for OTP versions prior to OTP 28. In
Erlang/OTP 28 and later, version 2 is the default representation, making this
diagnostic unnecessary. Developers can use the old representation by passing the
{version, 1} flag to new/1 and from_list/2.
Functions that work on two sets, such as union/2 and similar, will work with
sets of different versions. In such cases, there is no guarantee about the
version of the returned set. Explicit conversion from the old version to the new
one can be done with sets:from_list(sets:to_list(Old), [{version,2}]).
For more information, see https://www.erlang.org/doc/man/sets.html