diff options
-rw-r--r-- | bootstrap/lib/stdlib/ebin/erl_lint.beam | bin | 76652 -> 76928 bytes | |||
-rw-r--r-- | lib/compiler/src/rec_env.erl | 4 | ||||
-rw-r--r-- | lib/compiler/test/error_SUITE.erl | 4 | ||||
-rw-r--r-- | lib/stdlib/src/erl_lint.erl | 25 | ||||
-rw-r--r-- | lib/stdlib/test/erl_lint_SUITE.erl | 15 |
5 files changed, 33 insertions, 15 deletions
diff --git a/bootstrap/lib/stdlib/ebin/erl_lint.beam b/bootstrap/lib/stdlib/ebin/erl_lint.beam Binary files differindex 1f1c43242d..ece262c1b0 100644 --- a/bootstrap/lib/stdlib/ebin/erl_lint.beam +++ b/bootstrap/lib/stdlib/ebin/erl_lint.beam diff --git a/lib/compiler/src/rec_env.erl b/lib/compiler/src/rec_env.erl index 77005a6f9d..31a1f8b0b7 100644 --- a/lib/compiler/src/rec_env.erl +++ b/lib/compiler/src/rec_env.erl @@ -34,8 +34,6 @@ -export_type([environment/0]). --import(erlang, [max/2]). - -ifdef(DEBUG). -export([test/1, test_custom/1, test_custom/2]). -endif. @@ -588,7 +586,7 @@ new_key(N, R, _T, F, Env) -> new_key(generate(N, R1), R1, 0, F, Env). start_range(Env) -> - max(env_size(Env) * ?START_RANGE_FACTOR, ?MINIMUM_RANGE). + erlang:max(env_size(Env) * ?START_RANGE_FACTOR, ?MINIMUM_RANGE). %% The previous key might or might not be used to compute the next key %% to be tried. It is currently not used. diff --git a/lib/compiler/test/error_SUITE.erl b/lib/compiler/test/error_SUITE.erl index 0874225a62..ec58a0761e 100644 --- a/lib/compiler/test/error_SUITE.erl +++ b/lib/compiler/test/error_SUITE.erl @@ -127,7 +127,7 @@ bif_clashes(Config) when is_list(Config) -> ">>, [], {error, - [{4,erl_lint,illegal_guard_expr}], + [{4,erl_lint,{illegal_guard_local_call,{length,1}}}], []} }], ?line [] = run2(Config, Ts3), Ts4 = [{bif_clashes9, @@ -140,7 +140,7 @@ bif_clashes(Config) when is_list(Config) -> ">>, [], {error, - [{5,erl_lint,illegal_guard_expr}], + [{5,erl_lint,{illegal_guard_local_call,{length,1}}}], []} }], ?line [] = run2(Config, Ts4), diff --git a/lib/stdlib/src/erl_lint.erl b/lib/stdlib/src/erl_lint.erl index c8bbb04e9a..077621ac91 100644 --- a/lib/stdlib/src/erl_lint.erl +++ b/lib/stdlib/src/erl_lint.erl @@ -197,19 +197,19 @@ format_error({define_import,{F,A}}) -> format_error({unused_function,{F,A}}) -> io_lib:format("function ~w/~w is unused", [F,A]); format_error({call_to_redefined_bif,{F,A}}) -> - io_lib:format("ambiguous call of redefined auto-imported BIF ~w/~w~n" + io_lib:format("ambiguous call of overridden auto-imported BIF ~w/~w~n" " - use erlang:~w/~w or \"-compile({no_auto_import,[~w/~w]}).\" " "to resolve name clash", [F,A,F,A,F,A]); format_error({call_to_redefined_old_bif,{F,A}}) -> - io_lib:format("ambiguous call of redefined pre R14 auto-imported BIF ~w/~w~n" + io_lib:format("ambiguous call of overridden pre R14 auto-imported BIF ~w/~w~n" " - use erlang:~w/~w or \"-compile({no_auto_import,[~w/~w]}).\" " "to resolve name clash", [F,A,F,A,F,A]); format_error({redefine_old_bif_import,{F,A}}) -> - io_lib:format("import directive redefines pre R14 auto-imported BIF ~w/~w~n" + io_lib:format("import directive overrides pre R14 auto-imported BIF ~w/~w~n" " - use \"-compile({no_auto_import,[~w/~w]}).\" " "to resolve name clash", [F,A,F,A]); format_error({redefine_bif_import,{F,A}}) -> - io_lib:format("import directive redefines auto-imported BIF ~w/~w~n" + io_lib:format("import directive overrides auto-imported BIF ~w/~w~n" " - use \"-compile({no_auto_import,[~w/~w]}).\" to resolve name clash", [F,A,F,A]); format_error({deprecated, MFA, ReplacementMFA, Rel}) -> @@ -231,6 +231,9 @@ format_error(illegal_pattern) -> "illegal pattern"; format_error(illegal_bin_pattern) -> "binary patterns cannot be matched in parallel using '='"; format_error(illegal_expr) -> "illegal expression"; +format_error({illegal_guard_local_call, {F,A}}) -> + io_lib:format("call to local/imported function ~w/~w is illegal in guard", + [F,A]); format_error(illegal_guard_expr) -> "illegal guard expression"; %% --- exports --- format_error({explicit_export,F,A}) -> @@ -1811,7 +1814,13 @@ gexpr({call,Line,{atom,_La,F},As}, Vt, St0) -> false -> {Asvt,add_error(Line, {explicit_export,F,A}, St1)} end; false -> - {Asvt,add_error(Line, illegal_guard_expr, St1)} + case is_local_function(St1#lint.locals,{F,A}) orelse + is_imported_function(St1#lint.imports,{F,A}) of + true -> + {Asvt,add_error(Line, {illegal_guard_local_call,{F,A}}, St1)}; + _ -> + {Asvt,add_error(Line, illegal_guard_expr, St1)} + end end; gexpr({call,Line,{remote,_Lr,{atom,_Lm,erlang},{atom,_Lf,F}},As}, Vt, St0) -> {Asvt,St1} = gexpr_list(As, Vt, St0), @@ -2076,12 +2085,14 @@ expr({call,Line,{atom,La,F},As}, Vt, St0) -> IsAutoBif = erl_internal:bif(F, A), AutoSuppressed = is_autoimport_suppressed(St2#lint.no_auto,{F,A}), Warn = is_warn_enabled(bif_clash, St2) and (not bif_clash_specifically_disabled(St2,{F,A})), - case ((not IsLocal) andalso IsAutoBif andalso (not AutoSuppressed)) of + Imported = imported(F, A, St2), + case ((not IsLocal) andalso (Imported =:= no) andalso + IsAutoBif andalso (not AutoSuppressed)) of true -> St3 = deprecated_function(Line, erlang, F, As, St2), {Asvt,St3}; false -> - {Asvt,case imported(F, A, St2) of + {Asvt,case Imported of {yes,M} -> St3 = check_remote_function(Line, M, F, As, St2), U0 = St3#lint.usage, diff --git a/lib/stdlib/test/erl_lint_SUITE.erl b/lib/stdlib/test/erl_lint_SUITE.erl index 01f494ee38..d0c0d68b4a 100644 --- a/lib/stdlib/test/erl_lint_SUITE.erl +++ b/lib/stdlib/test/erl_lint_SUITE.erl @@ -2252,7 +2252,7 @@ otp_5878(Config) when is_list(Config) -> {15,erl_lint,{undefined_field,r3,q}}, {17,erl_lint,{undefined_field,r,q}}, {21,erl_lint,illegal_guard_expr}, - {23,erl_lint,illegal_guard_expr}], + {23,erl_lint,{illegal_guard_local_call,{l,0}}}], []} = run_test2(Config, Ill1, [warn_unused_record]), @@ -2492,7 +2492,7 @@ bif_clash(Config) when is_list(Config) -> binary:part(B,X,Y). ">>, [], - {errors,[{3,erl_lint,illegal_guard_expr}],[]}}, + {errors,[{3,erl_lint,{illegal_guard_local_call,{binary_part,2}}}],[]}}, %% no_auto_import is not like nowarn_bif_clash, it actually removes the autoimport {clash9, <<"-export([x/1]). @@ -2599,7 +2599,16 @@ bif_clash(Config) when is_list(Config) -> binary_part(A,B,C+1). ">>, [], - {errors,[{4,erl_lint,illegal_guard_expr}],[]}} + {errors,[{4,erl_lint,illegal_guard_expr}],[]}}, + %% Not with local functions either + {clash20, + <<"-export([binary_port/3]). + -import(x,[binary_part/3]). + binary_port(A,B,C) -> + binary_part(A,B,C). + ">>, + [warn_unused_import], + {warnings,[{2,erl_lint,{redefine_bif_import,{binary_part,3}}}]}} ], ?line [] = run(Config, Ts), |