|
24 | 24 |
|
25 | 25 | % CHANGES
|
26 | 26 | % =======
|
27 |
| -% |
28 | 27 | % Significant changes to the specification.
|
29 |
| -% |
30 | 28 | % 2.2
|
31 | 29 | % - Specify whether the values of literal expressions override Object.==.
|
32 | 30 | % - Allow Type objects as case expressions and const map keys.
|
|
38 | 36 | % Function.
|
39 | 37 | % - Generalize specification of type aliases such that they can denote any
|
40 | 38 | % type, not just function types.
|
41 |
| -% - Added requirement that the iterator of a for-in statement must have |
42 |
| -% type `Iterator`. |
43 | 39 | %
|
44 | 40 | % 2.1
|
45 | 41 | % - Remove 64-bit constraint on integer literals compiled to JavaScript numbers.
|
@@ -12291,33 +12287,24 @@ \subsubsection{For-in}
|
12291 | 12287 | \LMLabel{for-in}
|
12292 | 12288 |
|
12293 | 12289 | \LMHash{}%
|
12294 |
| -Let $D$ be derived from \syntax{<finalConstVarOrType>?}. |
12295 |
| -A for statement of the form \code{\FOR{} ($D$ \id{} \IN{} $e$)\,\,$S$} |
12296 |
| -is then treated as the following code, |
12297 |
| -where $\id_1$ and $\id_2$ are fresh identifiers: |
| 12290 | +Let $D$ be derived from \syntax{<finalConstVarOrType>?} |
| 12291 | +and let $n0$ be an identifier that does not occur anywhere in the program. |
| 12292 | +A for statement of the form \code{\FOR{} ($D$ \id{} \IN{} $e$) $s$} is equivalent to the following code: |
12298 | 12293 |
|
12299 | 12294 | \begin{normativeDartCode}
|
12300 |
| -$T$ $\id_1$ = $e$; |
12301 |
| -\VAR{} $\id_2$ = $id_1$.iterator; |
12302 |
| -\WHILE{} ($\id_2$.moveNext()) \{ |
12303 |
| -\ \ $D$ \id{} = $\id_2$.current; |
12304 |
| -\ \ $S$ |
| 12295 | +\VAR{} $n0$ = $e$.iterator; |
| 12296 | +\WHILE{} ($n0$.moveNext()) \{ |
| 12297 | +\ \ $D$ \id{} = $n0$.current; |
| 12298 | +\ \ $s$ |
12305 | 12299 | \}
|
12306 | 12300 | \end{normativeDartCode}
|
12307 | 12301 |
|
12308 |
| -\noindent |
12309 |
| -If the static type of $e$ is a top type |
12310 |
| -(\ref{superBoundedTypes}) |
12311 |
| -then $T$ is \code{Iterable<dynamic>}, |
12312 |
| -otherwise $T$ is the static type of $e$. |
12313 |
| -It is a compile-time error if $T$ is not assignable to \code{Iterable<dynamic>}. |
12314 |
| - |
12315 |
| -\commentary{ |
12316 |
| -It follows that it is a compile-time error |
12317 |
| -if $D$ is empty and \id{} is a final variable; |
12318 |
| -and it is a dynamic error if $e$ has a top type, |
12319 |
| -but $e$ evaluates to an instance of a type |
12320 |
| -which is not a subtype of \code{Iterable<dynamic>}. |
| 12302 | +For purposes of static typechecking, |
| 12303 | +this code is checked under the assumption that $n0$ is declared to be of type $T$, |
| 12304 | +where $T$ is the static type of \code{$e$.iterator}. |
| 12305 | + |
| 12306 | +\commentary{ |
| 12307 | +It follows that it is a compile-time error if $D$ is empty and \id{} is a final variable. |
12321 | 12308 | }
|
12322 | 12309 |
|
12323 | 12310 |
|
|
0 commit comments