summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Gustavsson <bjorn@erlang.org>2023-05-08 08:55:03 +0200
committerGitHub <noreply@github.com>2023-05-08 08:55:03 +0200
commit6272f6bde079e65876627cb569026f2014049fd5 (patch)
treeb18754005591e6598f2c6b4d79f7e96df89697e9
parentf4df4fa8616a18fdae4194923df2d17efaa77ca5 (diff)
parent3d158fba7e3a1d5c7dc7d78cb8a45b0eeb2c90da (diff)
downloaderlang-6272f6bde079e65876627cb569026f2014049fd5.tar.gz
Merge pull request #7210 from bjorng/bjorn/upcoming-incompatibilities
Add notes about two upcoming incompatibilities OTP-18574
-rw-r--r--system/doc/general_info/upcoming_incompatibilities.xml60
1 files changed, 60 insertions, 0 deletions
diff --git a/system/doc/general_info/upcoming_incompatibilities.xml b/system/doc/general_info/upcoming_incompatibilities.xml
index 04ab4459c0..8538067b57 100644
--- a/system/doc/general_info/upcoming_incompatibilities.xml
+++ b/system/doc/general_info/upcoming_incompatibilities.xml
@@ -53,6 +53,7 @@
</section>
<section>
+ <marker id="maybe_expr"/>
<title>Feature maybe_expr will be enabled by default</title>
<p>
As of OTP 27, the <c>maybe_expr</c> feature will be approved
@@ -119,6 +120,65 @@
the regular expression before matching with it.</p></item>
</list>
</section>
+
+ <section>
+ <marker id="float_matching"/>
+ <title>0.0 and -0.0 will no longer be exactly equal</title>
+
+ <p>Currently, the floating point numbers <c>0.0</c> and <c>-0.0</c>
+ have distinct internal representations. That can be seen if they are
+ converted to binaries:</p>
+ <pre>
+1&gt; <input>&lt;&lt;0.0/float&gt;&gt;.</input>
+&lt;&lt;0,0,0,0,0,0,0,0&gt;&gt;
+2&gt; <input>&lt;&lt;-0.0/float&gt;>.</input>
+&lt;&lt;128,0,0,0,0,0,0,0>></pre>
+
+ <p>However, when they are matched against each other or compared
+ using the <c>=:=</c> operator, they are considered to be
+ equal. Thus, <c>0.0 =:= -0.0</c> currently returns
+ <c>true</c>.</p>
+
+ <p>In Erlang/OTP 27, <c>0.0 =:= -0.0</c> will return <c>false</c>, and matching
+ <c>0.0</c> against <c>-0.0</c> will fail. When used as map keys, <c>0.0</c> and
+ <c>-0.0</c> will be considered to be distinct.</p>
+
+ <p>The <c>==</c> operator will continue to return <c>true</c>
+ for <c>0.0 == -0.0</c>.</p>
+
+ <p>To help to find code that might need to be revised, in OTP 27
+ there will be a new compiler warning when matching against
+ <c>0.0</c> or comparing to that value using the <c>=:=</c>
+ operator. The warning can be suppressed by matching against
+ <c>+0.0</c> instead of <c>0.0</c>.</p>
+
+ <p>We plan to introduce the same warning in OTP 26.1, but by default it
+ will be disabled.</p>
+ </section>
+
+ <section>
+ <marker id="singleton_typevars"/>
+ <title>Singleton type variables will become a compile-time error</title>
+
+ <p>Before Erlang/OTP 26, the compiler would silenty accept the
+ following spec:</p>
+
+ <pre>
+-spec f(Opts) -> term() when
+ Opts :: {ok, Unknown} | {error, Unknown}.
+f(_) -> error.</pre>
+
+ <p>In OTP 26, the compiler emits a warning pointing out that the type variable
+ <c>Unknown</c> is unbound:</p>
+
+ <pre>
+t.erl:6:18: Warning: type variable 'Unknown' is only used once (is unbound)
+% 6| Opts :: {ok, Unknown} | {error, Unknown}.
+% | ^</pre>
+
+ <p>In OTP 27, that warning will become an error.</p>
+ </section>
+
</section>
<section>