Skip to content

Commit

Permalink
Document previously hidden (though very useful) compiler options
Browse files Browse the repository at this point in the history
  • Loading branch information
paulo-ferraz-oliveira committed Dec 10, 2020
1 parent 810d679 commit 5e4e67c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
14 changes: 14 additions & 0 deletions lib/compiler/doc/src/compile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,20 @@ module.beam: module.erl \
fallbacks by accident. Use this option to turn off this kind of
warnings.</p>
</item>

<tag><c>warn_missing_spec</c></tag>
<item>
<p>By default, warnings are not emitted when a specification
(or contract) for an exported function is not given. Use this
option to turn on this kind of warning.</p>
</item>

<tag><c>warn_missing_spec_all</c></tag>
<item>
<p>By default, warnings are not emitted when a specification
(or contract) for an exported or unexported function is not
given. Use this option to turn on this kind of warning.</p>
</item>
</taglist>

<p>Another class of warnings is generated by the compiler
Expand Down
25 changes: 23 additions & 2 deletions lib/stdlib/test/erl_lint_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@
otp_14285/1, otp_14378/1,
external_funs/1,otp_15456/1,otp_15563/1,
unused_type/1,removed/1, otp_16516/1,
inline_nifs/1]).
inline_nifs/1,
warn_missing_spec/1]).

suite() ->
[{ct_hooks,[ts_install_cth]},
Expand All @@ -93,7 +94,7 @@ all() ->
record_errors, otp_11879_cont, non_latin1_module, otp_14323,
stacktrace_syntax, otp_14285, otp_14378, external_funs,
otp_15456, otp_15563, unused_type, removed, otp_16516,
inline_nifs].
inline_nifs, warn_missing_spec].

groups() ->
[{unused_vars_warn, [],
Expand Down Expand Up @@ -4448,6 +4449,26 @@ inline_nifs(Config) ->
{warnings,[{2,erl_lint,nif_inline}]}}],
[] = run(Config, Ts).

warn_missing_spec(Config) ->
Test = <<"-export([external_with_spec/0, external_no_spec/0]).
-spec external_with_spec() -> ok.
external_with_spec() -> ok.
external_no_spec() -> ok.
-spec internal_with_spec() -> ok.
internal_with_spec() -> ok.
internal_no_spec() -> ok.">>,
run(Config, [
{warn_missing_spec, Test, [warn_missing_spec],
{warnings, [{6, erl_lint, {missing_spec, {external_no_spec, 0}}}]}},
{warn_missing_spec_all, Test, [warn_missing_spec_all],
{warnings, [{6, erl_lint, {missing_spec, {external_no_spec, 0}}},
{11, erl_lint, {missing_spec, {internal_no_spec, 0}}}]}}
]).

format_error(E) ->
lists:flatten(erl_lint:format_error(E)).

Expand Down

0 comments on commit 5e4e67c

Please sign in to comment.