Index: docs/language/dartLangSpec.tex |
diff --git a/docs/language/dartLangSpec.tex b/docs/language/dartLangSpec.tex |
index 3850f200dfcfc00dea26f2a7b80fdf71a2c7f3a8..7271f8cb7898c199a411f12dd7ee898890226826 100644 |
--- a/docs/language/dartLangSpec.tex |
+++ b/docs/language/dartLangSpec.tex |
@@ -7,8 +7,7 @@ |
\usepackage{lmodern} |
\newcommand{\code}[1]{{\sf #1}} |
\title{Dart Programming Language Specification \\ |
-(4th edition draft)\\ |
-{\large Version 1.11}} |
+{\large Version 1.13}} |
% For information about Location Markers (and in particular the |
% commands \LMHash and \LMLabel), see the long comment at the |
@@ -3874,7 +3873,7 @@ Let $T$ be the static type of $o$. It is a static type warning if $T$ does not |
\item |
$T$ or a superinterface of $T$ is annotated with an annotation denoting a constant identical to the constant \code{@proxy} defined in \code{dart:core}. Or |
\item $T$ is \code{Type}, $e$ is a constant type literal and the class corresponding to $e$ has a static getter named $m$. |
-\item $T$ is \code{Function} and $m$ is \CALL. \rationale {The type \code{Function} is treated as if it has a \code{call} method for any possible signature of \CALL. The expectation is that any concrete subclass of \code{Function} will implement \CALL. Note that a warning will be issue if this is not the case. Furthermore, any use of \CALL{} on a subclass of \code{Function} that fails to implement \CALL{} will also provoke a a warning, as this exemption is limited to type \code{Function}, and does not apply to its subtypes. |
+\item $T$ is \code{Function} and $m$ is \CALL. \rationale {The type \code{Function} is treated as if it has a \code{call} method for any possible signature of \CALL. The expectation is that any concrete subclass of \code{Function} will implement \CALL. Note that a warning will be issue if this is not the case. Furthermore, any use of \CALL{} on a subclass of \code{Function} that fails to implement \CALL{} will also provoke a warning, as this exemption is limited to type \code{Function}, and does not apply to its subtypes. |
} |
\end{itemize} |
@@ -6457,24 +6456,38 @@ An {\em assert statement} is used to disrupt normal execution if a given boolean |
\begin{grammar} |
{\bf assertStatement:} |
- assert `(' conditionalExpression `)' `{\escapegrammar ;}' |
+ assert `(' conditionalExpression (`,' expression)? `)' `{\escapegrammar ;}' |
. |
\end{grammar} |
\LMHash{} |
-The assert statement has no effect in production mode. In checked mode, execution of an assert statement \code{\ASSERT{}($e$);} proceeds as follows: |
+The assert statement has no effect in production mode. In checked mode, execution of an assert statement \code{\ASSERT{}($e$);} or \code{\ASSERT{}($e$, $s$);} proceeds as follows: |
\LMHash{} |
The conditional expression $e$ is evaluated to an object $o$. If the class of $o$ is a subtype of \code{Function} then let $r$ be the result of invoking $o$ with no arguments. Otherwise, let $r$ be $o$. |
-It is a dynamic type error if $o$ is not of type \code{bool} or of type \code{Function}, or if $r$ is not of type \code{bool}. If $r$ is \FALSE{}, we say that the assertion failed. If $r$ is \TRUE{}, we say that the assertion succeeded. If the assertion succeeded, execution of the assert statement is complete. If the assertion failed, an \code{AssertionError} is thrown. |
+It is a dynamic type error if $o$ is not of type \code{bool} or of type \code{Function}, or if $r$ is not of type \code{bool}. If $r$ is \FALSE{}, we say that the assertion failed. If $r$ is \TRUE{}, we say that the assertion succeeded. If the assertion succeeded, execution of the assert statement is complete. |
+ |
+\LMHash{} |
+If the assertion failed, and the assertion is of the form \code{\ASSERT{}($e$);} an \cd{AssertionError} is thrown. |
+ |
+If the assertion failed and the assertion is of the form \code{\ASSERT{}($e$, $s$);} then the expression $s$ is evaluated to a value $o_s$. If evaluation of $s$ fails, an \cd{AssertionError} is thrown. Otherwise, the \cd{toString()} method is invoked on $o_s$ resulting in a string object $m$. If the invocation of \cd{toString()} throws an exception, an \cd{AssertionError} is thrown. Otherwise, |
Lasse Reichstein Nielsen
2015/11/05 16:22:25
Calling o_s.toString is not guaranteed to result i
Brian Wilkerson
2015/11/05 17:04:37
True. We have the same problem for string interpol
Bob Nystrom
2015/11/05 17:50:04
fails, an \cd{AssertionError} is thrown.
I don't
gbracha
2015/11/05 19:25:01
Interestingly, the original spec would ensure that
Paul Berry
2015/11/05 19:35:26
Personally, I feel the opposite way. I use assert
floitsch
2015/11/18 21:16:36
Late to the party...
I'm not going to make this ea
gbracha
2015/11/24 20:26:04
So we are going around in circles. The original sp
|
+an \cd{AssertionError} $x$ is created with error message $m$. |
Lasse Reichstein Nielsen
2015/11/05 16:22:25
Maybe if evaluation of $s$ fails, we should let th
gbracha
2015/11/05 19:25:01
So if we go back to propagating failures in messag
|
+ |
+\rationale { |
+The optional argument $s$ is intended to allow a suitable message to be associated with the assertion. An implementation should endeavor to display the message $m$ in a manner that is useful to the developer. |
+} |
+ |
+\commentary{ |
+The definition above implies that $s$ is not evaluated if the assertion succeeded. |
+} |
%\Q{Might be cleaner to define it as \code{if (!$e$) \{\THROW{} \NEW{} AssertionError();\}} (in checked mode only). |
%What about an error message as part of the assert?} |
\LMHash{} |
- It is a static type warning if the type of $e$ may not be assigned to either \code{bool} or $() \rightarrow$ \code{bool}. |
+ It is a static type warning if the type of $e$ may not be assigned to either \code{bool} or $() \rightarrow$ \code{bool}. |
-\rationale{Why is this a statement, not a built in function call? Because it is handled magically so it has no effect and no overhead in production mode. Also, in the absence of final methods. one could not prevent it being overridden (though there is no real harm in that). It cannot be viewed as a function call that is being optimized away because the argument might have side effects. |
+\rationale{Why is this a statement, not a built in function call? Because it is handled magically so it has no effect and no overhead in production mode. Also, in the absence of final methods. one could not prevent it being overridden (though there is no real harm in that). It cannot be viewed as a function call that is being optimized away because the argument might have side effects. And lastly, the optional message would have to be evaluated in all cases if \ASSERT{} were a function. |
} |
%If a lexically visible declaration named \code{assert} is in scope, an assert statement |
@@ -7321,7 +7334,7 @@ A function type $(T_1, \ldots T_n, \{T_{x_1}$ $x_1, \ldots, T_{x_k}$ $x_k\}) \ri |
\item $\forall i \in 1 .. n, T_i \Longleftrightarrow S_i$. |
\item $k \ge m$ and $y_i \in \{x_1, \ldots, x_k\}, i \in 1 .. m$. |
%\{x_1, \ldots, x_k\}$ is a superset of $\{y_1, \ldots, y_m\}$. |
-\item For all $y_i \in \{y_1, \ldots, y_m\}, y_i = x_j \Rightarrow T_j \Longleftrightarrow S_i$ |
+\item For all $y_i \in \{y_1, \ldots, y_m\}, y_i = x_j \Rightarrow T_{x_j} \Longleftrightarrow S_{y_i}$ |
\end{enumerate} |
%In addition, a function type $(T_1, \ldots, Tn, [T_{n+1} x_{n+1}, \ldots, T_{n+k} x_{n+k}]) \rightarrow T$ is a subtype of the function type $(T_1, \ldots, T_n, T_{n+1} , [T_{n+2} x_{n+2}, \ldots, T_{n+k} x_{n+k}]) \rightarrow T$. |