File 1115-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
@@ -677,6 +677,20 @@ module.beam: module.erl \
<p>Turns off warnings for unused record types. Default is to
emit warnings for unused locally defined record types.</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
@@ -69,7 +69,8 @@
stacktrace_syntax/1,
otp_14285/1, otp_14378/1,
external_funs/1,otp_15563/1,
- unused_type/1, otp_16516/1]).
+ unused_type/1, otp_16516/1,
+ warn_missing_spec/1]).
suite() ->
[{ct_hooks,[ts_install_cth]},
@@ -91,7 +92,8 @@ all() ->
otp_11851, otp_11879, otp_13230,
record_errors, otp_11879_cont, non_latin1_module, otp_14323,
stacktrace_syntax, otp_14285, otp_14378, external_funs,
- otp_15563, unused_type, otp_16516].
+ otp_15563, unused_type, otp_16516,
+ warn_missing_spec].
groups() ->
[{unused_vars_warn, [],
@@ -4319,6 +4321,26 @@ inline_nifs(Config) ->
{5,erl_lint,{unused_var,'V2'}}]}}],
[] = 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