diff options
author | Patrik Nyblom <[email protected]> | 2010-06-01 11:12:14 +0200 |
---|---|---|
committer | Patrik Nyblom <[email protected]> | 2010-06-02 16:47:29 +0200 |
commit | 334e4acd61605111712edefe874f98d030f0d25c (patch) | |
tree | 63260950d7af4a7b1194f548985d3cf8d9ac7303 /lib | |
parent | dcd4d82b67c250987b17f61043d764d446ed00e3 (diff) | |
download | otp-334e4acd61605111712edefe874f98d030f0d25c.tar.gz otp-334e4acd61605111712edefe874f98d030f0d25c.tar.bz2 otp-334e4acd61605111712edefe874f98d030f0d25c.zip |
Change warning to error for nowarn_bif_clash compiler directive
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compiler/doc/src/compile.xml | 35 | ||||
-rw-r--r-- | lib/stdlib/src/erl_lint.erl | 25 | ||||
-rw-r--r-- | lib/stdlib/test/erl_lint_SUITE.erl | 26 |
3 files changed, 35 insertions, 51 deletions
diff --git a/lib/compiler/doc/src/compile.xml b/lib/compiler/doc/src/compile.xml index 3a70f6277b..e1f24b602d 100644 --- a/lib/compiler/doc/src/compile.xml +++ b/lib/compiler/doc/src/compile.xml @@ -355,51 +355,34 @@ <tag><c>nowarn_bif_clash</c></tag> <item> - <p>By default, the compiler will issue an error or warning - when replacing an auto-imported BIF. For local functions - having names clashing with an auto-imported BIF, the error - or warning is issued whenever it is called without using a - module prefix. For explicitly imported functions, the - error or warning will be issued as soon as it's imported - (regardless of calls). If the auto-imported BIF was present - before OTP R14A it will be a fatal error to override it, - otherwise only a warning will be issued.</p> + <p>This option is removed, it will generate a fatal error if used.</p> <warning> <p>Beginning with R14A, the compiler no longer calls the auto-imported BIF if the name clashes with a local or explicitly imported function and a call without explicit module name is issued. Instead the local or imported - function is called. Use of <c>nowarn_bif_clash</c> makes a + function is called. Still accepting <c>nowarn_bif_clash</c> would makes a module calling functions clashing with autoimported BIFs compile with both the old and new compilers, but with - completely different semantics, why a warning is always - issued if any code uses this option.</p> + completely different semantics, why the option was removed.</p> <p>The use of this option has always been strongly discouraged. - From OTP R14A and forward it's also deprecated.</p> - <p>The only module who actually could have some legitimate use for - this option is the module <c>erlang</c>, which in - itself contains auto-imported functions, other modules - should never use it.</p> + From OTP R14A and forward it's an error to use it.</p> <p>To resolve BIF clashes, use explicit module names or the - <c>{no_auto_import,[F/A]}</c> directive.</p> - <p><c>nowarn_bif_clash</c> <em>will</em> be removed in a future release.</p> + <c>{no_auto_import,[F/A]}</c> compiler directive.</p> </warning> </item> <tag><c>{nowarn_bif_clash, FAs}</c></tag> <item> - <p>Turns off warnings as <c>nowarn_bif_clash</c> but only - for the mentioned local functions. <c>FAs</c> is a tuple - <c>{Name,Arity}</c> or a list of such tuples.</p> + <p>This option is removed, it will generate a fatal error if used.</p> + <warning> <p>The use of this option has always been strongly discouraged. - From OTP R14A and forward it's also deprecated and a warning will be issued - whenever it is used.</p> + From OTP R14A and forward it's an error to use it.</p> <p>To resolve BIF clashes, use explicit module names or the - <c>{no_auto_import,[F/A]}</c> directive instead.</p> - <p><c>nowarn_bif_clash</c> <em>will</em> be removed in a future release.</p> + <c>{no_auto_import,[F/A]}</c> compiler directive.</p> </warning> </item> diff --git a/lib/stdlib/src/erl_lint.erl b/lib/stdlib/src/erl_lint.erl index 631ad0c1e3..29a949432b 100644 --- a/lib/stdlib/src/erl_lint.erl +++ b/lib/stdlib/src/erl_lint.erl @@ -163,8 +163,8 @@ format_error({bad_nowarn_unused_function,{F,A}}) -> io_lib:format("function ~w/~w undefined", [F,A]); format_error({bad_nowarn_bif_clash,{F,A}}) -> io_lib:format("function ~w/~w undefined", [F,A]); -format_error(deprecated_nowarn_bif_clash) -> - io_lib:format("compile directive nowarn_bif_clash is deprecated,~n" +format_error(disallowed_nowarn_bif_clash) -> + io_lib:format("compile directive nowarn_bif_clash is no longer allowed,~n" " - use explicit module names or -compile({no_auto_import, [F/A]})", []); format_error({bad_nowarn_deprecated_function,{M,F,A}}) -> io_lib:format("~w:~w/~w is not a deprecated function", [M,F,A]); @@ -553,7 +553,7 @@ forms(Forms0, St0) -> Forms = eval_file_attribute(Forms0, St0), Locals = local_functions(Forms), AutoImportSuppressed = auto_import_suppressed(St0#lint.compile), - StDeprecated = deprecated_compile_flags(Forms,St0), + StDeprecated = disallowed_compile_flags(Forms,St0), %% Line numbers are from now on pairs {File,Line}. St1 = includes_qlc_hrl(Forms, StDeprecated#lint{locals = Locals, no_auto = AutoImportSuppressed}), @@ -762,22 +762,23 @@ not_deprecated(Forms, St0) -> St1 = func_line_warning(bad_nowarn_deprecated_function, Bad, St0), St1#lint{not_deprecated = ordsets:from_list(Nowarn)}. -deprecated_compile_flags(Forms, St0) -> +%% The nowarn_bif_clash directive is not only deprecated, it's actually an error from R14A +disallowed_compile_flags(Forms, St0) -> %% There are (still) no line numbers in St0#lint.compile. - Warnings0 = [ {St0#lint.file,{L,erl_lint,deprecated_nowarn_bif_clash}} || + Errors0 = [ {St0#lint.file,{L,erl_lint,disallowed_nowarn_bif_clash}} || {attribute,[{line,{_,L}}],compile,nowarn_bif_clash} <- Forms ], - Warnings1 = [ {St0#lint.file,{L,erl_lint,deprecated_nowarn_bif_clash}} || + Errors1 = [ {St0#lint.file,{L,erl_lint,disallowed_nowarn_bif_clash}} || {attribute,[{line,{_,L}}],compile,{nowarn_bif_clash, {_,_}}} <- Forms ], Disabled = (not is_warn_enabled(bif_clash, St0)), - Warnings = if - Disabled andalso Warnings0 =:= [] -> - [{St0#lint.file,{erl_lint,deprecated_nowarn_bif_clash}} | St0#lint.warnings]; + Errors = if + Disabled andalso Errors0 =:= [] -> + [{St0#lint.file,{erl_lint,disallowed_nowarn_bif_clash}} | St0#lint.errors]; Disabled -> - Warnings0 ++ Warnings1 ++ St0#lint.warnings; + Errors0 ++ Errors1 ++ St0#lint.errors; true -> - Warnings1 ++ St0#lint.warnings + Errors1 ++ St0#lint.errors end, - St0#lint{warnings=Warnings}. + St0#lint{errors=Errors}. %% post_traversal_check(Forms, State0) -> State. %% Do some further checking after the forms have been traversed and diff --git a/lib/stdlib/test/erl_lint_SUITE.erl b/lib/stdlib/test/erl_lint_SUITE.erl index 4a366f6a28..8fe7881081 100644 --- a/lib/stdlib/test/erl_lint_SUITE.erl +++ b/lib/stdlib/test/erl_lint_SUITE.erl @@ -1785,7 +1785,7 @@ otp_5362(Config) when is_list(Config) -> {16,erl_lint,{field_name_is_variable,ok,'Var'}}]}}, %% Nowarn_bif_clash has changed behaviour as local functions - %% nowdays supersede auto-imported BIFs, why nowarn_bif_clash in itself generates a warning + %% nowdays supersede auto-imported BIFs, why nowarn_bif_clash in itself generates an error %% (OTP-8579) /PaN {otp_5362_4, <<"-compile(nowarn_deprecated_function). @@ -1810,8 +1810,8 @@ otp_5362(Config) when is_list(Config) -> spawn(A). ">>, {[nowarn_unused_function]}, - {warnings, - [{2,erl_lint,deprecated_nowarn_bif_clash}]}}, + {errors, + [{2,erl_lint,disallowed_nowarn_bif_clash}],[]}}, %% The special nowarn_X are not affected by general warn_X. {otp_5362_6, @@ -1824,8 +1824,8 @@ otp_5362(Config) when is_list(Config) -> {[nowarn_unused_function, warn_deprecated_function, warn_bif_clash]}, - {warnings, - [{2,erl_lint,deprecated_nowarn_bif_clash}]}}, + {errors, + [{2,erl_lint,disallowed_nowarn_bif_clash}],[]}}, {otp_5362_7, <<"-export([spawn/1]). @@ -1840,10 +1840,10 @@ otp_5362(Config) when is_list(Config) -> spawn(A). ">>, {[nowarn_unused_function]}, - {error,[{4,erl_lint,{bad_nowarn_bif_clash,{spawn,2}}}], - [{3,erl_lint,deprecated_nowarn_bif_clash}, - {4,erl_lint,deprecated_nowarn_bif_clash}, - {5,erl_lint,{bad_nowarn_deprecated_function,{3,hash,-1}}}, + {error,[{3,erl_lint,disallowed_nowarn_bif_clash}, + {4,erl_lint,disallowed_nowarn_bif_clash}, + {4,erl_lint,{bad_nowarn_bif_clash,{spawn,2}}}], + [{5,erl_lint,{bad_nowarn_deprecated_function,{3,hash,-1}}}, {5,erl_lint,{bad_nowarn_deprecated_function,{erlang,hash,-1}}}, {5,erl_lint,{bad_nowarn_deprecated_function,{{a,b,c},hash,-1}}}]} }, @@ -1882,8 +1882,8 @@ otp_5362(Config) when is_list(Config) -> {[nowarn_unused_function, warn_deprecated_function, warn_bif_clash]}, - {warnings, - [{2,erl_lint,deprecated_nowarn_bif_clash}]}} + {errors, + [{2,erl_lint,disallowed_nowarn_bif_clash}],[]}} ], @@ -2409,7 +2409,7 @@ bif_clash(Config) when is_list(Config) -> [], {errors,[{2,erl_lint,{call_to_redefined_old_bif,{size,1}}}],[]}}, - %% Verify that (some) warnings can be turned off. + %% Verify that warnings can not be turned off in the old way. {clash2, <<"-export([t/1,size/1]). t(X) -> @@ -2425,7 +2425,7 @@ bif_clash(Config) when is_list(Config) -> abs(X) -> erlang:abs(X). ">>, {[nowarn_unused_function,nowarn_bif_clash]}, - {warnings,[{erl_lint,deprecated_nowarn_bif_clash}]}}, + {errors,[{erl_lint,disallowed_nowarn_bif_clash}],[]}}, %% As long as noone calls an overridden BIF, it's totally OK {clash3, <<"-export([size/1]). |