Skip to main content

L1209 - Redefine import

Error

-import(lists, [map/2]).
-import(lists, [map/2]).
%% ^^^^^^ 💡 error: function map/2 already imported from lists

Explanation

This error occurs when you attempt to import the same function from the same module more than once using the -import directive.

Each function can only be imported once from a given module. Duplicate imports are redundant and not allowed.

To fix this error:

  1. Remove the duplicate import statement
  2. Ensure each function is imported only once per module
%% Correct approach - single import
-import(lists, [map/2]).

foo(List) ->
map(fun(X) -> X * 2 end, List).