File 0280-Document-previously-hidden-though-very-useful-compil.patch of Package erlang
From 5e4e67c1a4cce3f813f7d4d27df8c2028c92c77f Mon Sep 17 00:00:00 2001
From: "Paulo F. Oliveira" <paulo.ferraz.oliveira@gmail.com>
Date: Tue, 8 Dec 2020 17:37:07 +0000
Subject: [PATCH] Document previously hidden (though very useful) compiler
options
---
lib/compiler/doc/src/compile.xml | 14 ++++++++++++++
lib/stdlib/test/erl_lint_SUITE.erl | 25 +++++++++++++++++++++++--
2 files changed, 37 insertions(+), 2 deletions(-)
diff --git a/lib/compiler/doc/src/compile.xml b/lib/compiler/doc/src/compile.xml
index 94180b4733..0e2f29aa9d 100644
--- a/lib/compiler/doc/src/compile.xml
+++ b/lib/compiler/doc/src/compile.xml
@@ -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
diff --git a/lib/stdlib/test/erl_lint_SUITE.erl b/lib/stdlib/test/erl_lint_SUITE.erl
index 20f8407f85..85567c88cb 100644
--- a/lib/stdlib/test/erl_lint_SUITE.erl
+++ b/lib/stdlib/test/erl_lint_SUITE.erl
@@ -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]},
@@ -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, [],
@@ -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)).
--
2.26.2