aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src
diff options
context:
space:
mode:
authorHans Bolinder <[email protected]>2019-05-07 07:51:45 +0200
committerHans Bolinder <[email protected]>2019-05-07 07:51:45 +0200
commitfb9cd9534b94fe8c24bc5412205dd97577894b59 (patch)
tree34038c43b0b0eda71b414a75f589b0701191e806 /lib/stdlib/src
parent8918de63a3d7ee8e1945a5c57331dddf1ee91fc2 (diff)
parent60e47cba35ff565a33b25ecb01e96881ab7fe0da (diff)
downloadotp-fb9cd9534b94fe8c24bc5412205dd97577894b59.tar.gz
otp-fb9cd9534b94fe8c24bc5412205dd97577894b59.tar.bz2
otp-fb9cd9534b94fe8c24bc5412205dd97577894b59.zip
Merge branch 'hasse/stdlib/check_spec_module/OTP-15563/ERL-845'
* hasse/stdlib/check_spec_module/OTP-15563/ERL-845: stdlib: Do not allow specs for functions in other modules
Diffstat (limited to 'lib/stdlib/src')
-rw-r--r--lib/stdlib/src/erl_lint.erl12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/stdlib/src/erl_lint.erl b/lib/stdlib/src/erl_lint.erl
index e0c37ca030..0cd0aef124 100644
--- a/lib/stdlib/src/erl_lint.erl
+++ b/lib/stdlib/src/erl_lint.erl
@@ -2,7 +2,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2018. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2019. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
@@ -386,6 +386,8 @@ format_error({redefine_callback, {F, A}}) ->
format_error({bad_callback, {M, F, A}}) ->
io_lib:format("explicit module not allowed for callback ~tw:~tw/~w",
[M, F, A]);
+format_error({bad_module, {M, F, A}}) ->
+ io_lib:format("spec for function ~w:~tw/~w from other module", [M, F, A]);
format_error({spec_fun_undefined, {F, A}}) ->
io_lib:format("spec for undefined function ~tw/~w", [F, A]);
format_error({missing_spec, {F,A}}) ->
@@ -3010,7 +3012,13 @@ spec_decl(Line, MFA0, TypeSpecs, St00 = #lint{specs = Specs, module = Mod}) ->
St1 = St0#lint{specs = dict:store(MFA, Line, Specs)},
case dict:is_key(MFA, Specs) of
true -> add_error(Line, {redefine_spec, MFA0}, St1);
- false -> check_specs(TypeSpecs, spec_wrong_arity, Arity, St1)
+ false ->
+ case MFA of
+ {Mod, _, _} ->
+ check_specs(TypeSpecs, spec_wrong_arity, Arity, St1);
+ _ ->
+ add_error(Line, {bad_module, MFA}, St1)
+ end
end.
%% callback_decl(Line, Fun, Types, State) -> State.