Skip to content

Commit 031824e

Browse files
authored
Change == in constant expressions to use primitive equality (#2874)
Change `==` in constant expressions to use primitive equality. Note that the left operand of `==` can also be an instance of `double`. They don't have primitive equality, but we did not want to introduce a breaking change, and `1.5 == 2.5` was a correct constant expression until now, so we keep it that way as a special exception.
1 parent a374667 commit 031824e

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

specification/dartLangSpec.tex

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
% version of the language which will actually be specified by the next stable
3636
% release of this document.
3737
%
38+
% Feb 2023
39+
% - Change the specification of constant expressions of the form `e1 == e2`
40+
% to use primitive equality.
41+
%
3842
% Dec 2022
3943
% - Change the definition of the type function 'flatten' to resolve soundness
4044
% issue, cf. SDK issue #49396.
@@ -8274,11 +8278,12 @@ \subsection{Constants}
82748278
\item
82758279
An expression of the form \code{$e_1$\,==\,$e_2$} is potentially constant
82768280
if $e_1$ and $e_2$ are both potentially constant expressions.
8277-
It is further constant if both $e_1$ and $e_2$ are constant and
8278-
either $e_1$ evaluates to an object that is an instance of
8279-
\code{int}, \code{double}, \code{String}, \code{bool} or \code{Null},
8280-
or if $e_2$ evaluates to the null object (\ref{null}).
8281-
%TODO: Consider adding enum instances here.
8281+
It is further constant if both $e_1$ and $e_2$ are constant, and
8282+
either $e_1$ evaluates to an instance of \code{double}
8283+
or an instance that that has primitive equality
8284+
(\ref{theOperatorEqualsEquals}),
8285+
or $e_2$ evaluates to the null object
8286+
(\ref{null}).
82828287

82838288
\item
82848289
An expression of the form \code{!$e_1$} is potentially constant

0 commit comments

Comments
 (0)