diff options
author | Patrik Nyblom <[email protected]> | 2010-05-21 12:02:04 +0200 |
---|---|---|
committer | Patrik Nyblom <[email protected]> | 2010-06-02 16:44:50 +0200 |
commit | a4894eabd2117dbb8e98365e9f87acf8c7a1ae33 (patch) | |
tree | fca9e53889a4907ac4e62e7d04bc2fd36906f869 /lib/stdlib/src/erl_lint.erl | |
parent | c48e315dbc8e41217ef51501afef30d02b7690ce (diff) | |
download | otp-a4894eabd2117dbb8e98365e9f87acf8c7a1ae33.tar.gz otp-a4894eabd2117dbb8e98365e9f87acf8c7a1ae33.tar.bz2 otp-a4894eabd2117dbb8e98365e9f87acf8c7a1ae33.zip |
Teach compiler to override autoimport with import
Diffstat (limited to 'lib/stdlib/src/erl_lint.erl')
-rw-r--r-- | lib/stdlib/src/erl_lint.erl | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/lib/stdlib/src/erl_lint.erl b/lib/stdlib/src/erl_lint.erl index 1e5464231d..89e31ba7e0 100644 --- a/lib/stdlib/src/erl_lint.erl +++ b/lib/stdlib/src/erl_lint.erl @@ -189,6 +189,8 @@ format_error({unused_function,{F,A}}) -> io_lib:format("function ~w/~w is unused", [F,A]); format_error({redefine_bif,{F,A}}) -> io_lib:format("redefining autoimported BIF ~w/~w", [F,A]); +format_error({redefine_bif_import,{F,A}}) -> + io_lib:format("import directive redefines autoimported BIF ~w/~w", [F,A]); format_error({deprecated, MFA, ReplacementMFA, Rel}) -> io_lib:format("~s is deprecated and will be removed in ~s; use ~s", @@ -1091,11 +1093,32 @@ import(Line, {Mod,Fs}, St) -> St#lint{imports=add_imports(list_to_atom(Mod1), Mfs, St#lint.imports)}; Efs -> - foldl(fun (Ef, St0) -> - add_error(Line, {redefine_import,Ef}, - St0) + {Err, St1} = + foldl(fun ({bif,{F,A},_}, {Err,St0}) -> + Warn = is_warn_enabled(bif_clash, St0), + {Err,if + Warn -> + add_warning + (Line, + {redefine_bif_import, {F,A}}, + St0); + true -> + St0 + end}; + (Ef, {_Err,St0}) -> + {true,add_error(Line, + {redefine_import,Ef}, + St0)} end, - St, Efs) + {false,St}, Efs), + if + not Err -> + St1#lint{imports= + add_imports(list_to_atom(Mod1), Mfs, + St#lint.imports)}; + true -> + St1 + end end; false -> add_error(Line, {bad_module_name, Mod1}, St) |