12
12
\usepackage[T1]{fontenc}
13
13
\usepackage{makeidx}
14
14
\usepackage{enumitem}
15
+ \usepackage{marvosym}
15
16
\makeindex
16
17
\title{Dart Programming Language Specification\\
17
18
{6th edition draft}\\
36
37
% version of the language which will actually be specified by the next stable
37
38
% release of this document.
38
39
%
40
+ % Jan, Feb 2023
41
+ % - Introduce `\DynamicError{}`, thus marking every introduction (definition)
42
+ % of a dynamic error by a lightning symbol in the right margin.
43
+ %
39
44
% Dec 2022
40
45
% - Change the definition of the type function 'flatten' to resolve soundness
41
46
% issue, cf. SDK issue #49396.
@@ -1464,7 +1469,7 @@ \subsection{Implicitly Induced Getters and Setters}
1464
1469
it will bind \id{} to the object that $x$ is bound to.
1465
1470
If this setter is executed
1466
1471
in a situation where the variable \id{} has been bound to an object,
1467
- a dynamic error occurs.
1472
+ a \DynamicError{ dynamic error} occurs.
1468
1473
1469
1474
\commentary{%
1470
1475
A late final variable declaration with no initializer is permitted.
@@ -1505,7 +1510,7 @@ \subsection{Implicitly Induced Getters and Setters}
1505
1510
will bind \id{} to the object that the argument $x$ is bound to.
1506
1511
An execution of the setter
1507
1512
in a situation where the variable \id{} has been bound to an object
1508
- will incur a dynamic error.
1513
+ will incur a \DynamicError{ dynamic error} .
1509
1514
1510
1515
\LMHash{}%
1511
1516
The scope into which the implicit getters and setters are introduced
@@ -1559,7 +1564,7 @@ \subsection{Implicitly Induced Getters and Setters}
1559
1564
but initialization and assignment is not the same thing.
1560
1565
When the receiver has type \DYNAMIC{}
1561
1566
such an assignment is not a compile-time error,
1562
- but if there is no such setter it will cause a dynamic error.%
1567
+ but if there is no such setter it will cause a \DynamicError{ dynamic error} .%
1563
1568
}
1564
1569
1565
1570
\LMHash{}%
@@ -1681,7 +1686,7 @@ \subsection{Evaluation of Implicit Variable Getters}
1681
1686
will evaluate to the object that \id{} is bound to.
1682
1687
Otherwise
1683
1688
(\commentary{when this variable has never been bound}),
1684
- the getter invocation incurs a dynamic error.
1689
+ the getter invocation incurs a \DynamicError{ dynamic error} .
1685
1690
\EndCase
1686
1691
1687
1692
\LMHash{}%
@@ -1788,7 +1793,7 @@ \subsection{Evaluation of Implicit Variable Getters}
1788
1793
will complete returning $o$.
1789
1794
An execution of the implicitly induced getter of \id{}
1790
1795
in a situation where the variable \id{} is unbound
1791
- will incur a dynamic error.
1796
+ will incur a \DynamicError{ dynamic error} .
1792
1797
\end{itemize}
1793
1798
1794
1799
% Reduce whitespace after itemized list: This is just an end symbol.
@@ -3996,7 +4001,7 @@ \subsubsection{Generative Constructors}
3996
4001
% This can occur due to a failing implicit cast.
3997
4002
unless the assigned object has a dynamic type
3998
4003
which is not a subtype of the declared type of the instance variable \id,
3999
- in which case a dynamic error occurs.
4004
+ in which case a \DynamicError{ dynamic error} occurs.
4000
4005
4001
4006
\commentary{%
4002
4007
The above rule allows initializing formals to be used as optional parameters:%
@@ -10281,7 +10286,7 @@ \subsubsection{Collection Literal Element Evaluation}
10281
10286
or the given \code{value} does not have the type \code{Value},
10282
10287
but it cannot occur after the pair has been appended to $s$.
10283
10288
\item
10284
- Otherwise, a dynamic error occurs.
10289
+ Otherwise, a \DynamicError{ dynamic error} occurs.
10285
10290
10286
10291
\commentary{%
10287
10292
This occurs when the target is an iterable respectively a map,
@@ -10336,7 +10341,8 @@ \subsubsection{Collection Literal Element Evaluation}
10336
10341
and if $\ell_2$ is not present then
10337
10342
$\EvaluateElement{\ell} := \LiteralSequence{}$.
10338
10343
% $o_b$ can have type \DYNAMIC.
10339
- If $o_b$ is neither \TRUE{} nor \FALSE{} then a dynamic error occurs.
10344
+ If $o_b$ is neither \TRUE{} nor \FALSE{}
10345
+ then a \DynamicError{dynamic error} occurs.
10340
10346
\EndCase
10341
10347
10342
10348
\LMHash{}%
@@ -10567,7 +10573,7 @@ \subsubsection{Lists}
10567
10573
An empty list has an empty set of indices.
10568
10574
A non-empty list has the index set $\{0, \ldots, n - 1\}$
10569
10575
where $n$ is the size of the list.
10570
- It is a dynamic error to attempt to access a list
10576
+ It is a \DynamicError{ dynamic error} to attempt to access a list
10571
10577
using an index that is not a member of its set of indices.
10572
10578
10573
10579
\rationale{%
@@ -10591,7 +10597,8 @@ \subsubsection{Lists}
10591
10597
Only run-time list literals can be mutated
10592
10598
after they are created.
10593
10599
% This error can occur because being constant is a dynamic property.
10594
- Attempting to mutate a constant list literal will result in a dynamic error.
10600
+ Attempting to mutate a constant list literal
10601
+ will result in a \DynamicError{dynamic error}.
10595
10602
10596
10603
\commentary{%
10597
10604
% The following is true either directly or indirectly: There is a \CONST{}
@@ -11360,7 +11367,7 @@ \subsubsection{Sets}
11360
11367
\LMHash{}%
11361
11368
A set may contain zero or more objects.
11362
11369
Sets have a method which can be used to insert objects;
11363
- this will incur a dynamic error if the set is not modifiable.
11370
+ this will incur a \DynamicError{ dynamic error} if the set is not modifiable.
11364
11371
Otherwise, when inserting an object $o_{\metavar{new}}$ into a set $s$,
11365
11372
if an object $o_{\metavar{old}}$ exists in $s$ such that
11366
11373
\code{$o_{\metavar{old}}$ == $o_{\metavar{new}}$} evaluates to \TRUE{}
@@ -11400,7 +11407,8 @@ \subsubsection{Sets}
11400
11407
and it is evaluated at run time.
11401
11408
Only run-time set literals can be mutated after they are created.
11402
11409
% This error can occur because being constant is a dynamic property, here.
11403
- Attempting to mutate a constant set literal will result in a dynamic error.
11410
+ Attempting to mutate a constant set literal
11411
+ will result in a \DynamicError{dynamic error}.
11404
11412
11405
11413
\commentary{%
11406
11414
% The following is true either directly or indirectly: There is a \CONST{}
@@ -11606,7 +11614,8 @@ \subsubsection{Maps}
11606
11614
and it is evaluated at run time.
11607
11615
Only run-time map literals can be mutated after they are created.
11608
11616
% This error can occur because being constant is a dynamic property, here.
11609
- Attempting to mutate a constant map literal will result in a dynamic error.
11617
+ Attempting to mutate a constant map literal
11618
+ will result in a \DynamicError{dynamic error}.
11610
11619
11611
11620
\commentary{%
11612
11621
% The following is true either directly or indirectly: There is a \CONST{}
@@ -11747,7 +11756,8 @@ \subsection{Throw}
11747
11756
}
11748
11757
11749
11758
\LMHash{}%
11750
- If $v$ is the null object (\ref{null}), then a dynamic error occurs.
11759
+ If $v$ is the null object (\ref{null})
11760
+ then a \DynamicError{dynamic error} occurs.
11751
11761
Otherwise let $t$ be a stack trace corresponding to the current execution state,
11752
11762
and the \THROW{} statement throws with $v$ as exception object
11753
11763
and $t$ as stack trace (\ref{expressionEvaluation}).
@@ -12261,7 +12271,7 @@ \subsubsection{New}
12261
12271
% This error can occur because being-loaded is a dynamic property.
12262
12272
If $T$ is a deferred type with prefix $p$,
12263
12273
then if $p$ has not been successfully loaded,
12264
- a dynamic error occurs.
12274
+ a \DynamicError{ dynamic error} occurs.
12265
12275
\EndCase
12266
12276
12267
12277
\LMHash{}%
@@ -13189,7 +13199,7 @@ \subsubsection{Binding Actuals to Formals}
13189
13199
If $r = 0$ and $s > 0$ then
13190
13200
if $f$ does not have default type arguments
13191
13201
(\ref{instantiationToBound})
13192
- then a dynamic error occurs.
13202
+ then a \DynamicError{ dynamic error} occurs.
13193
13203
Otherwise replace the actual type argument list:
13194
13204
Let $r$ be $s$ and let $t_i$ for $i \in 1 .. s$ be the result of
13195
13205
instantiation to bound
@@ -16154,7 +16164,8 @@ \subsection{Assignment}
16154
16164
in which case $v$ has no initializer and is not definitely assigned,
16155
16165
or a compile-time error would have occurred%
16156
16166
}).
16157
- If $v$ has previously been bound to an object then a dynamic error occurs.
16167
+ If $v$ has previously been bound to an object
16168
+ then a \DynamicError{dynamic error} occurs.
16158
16169
Otherwise, $v$ is bound to $o$, and then $a$ evaluates to $o$
16159
16170
(\ref{expressionEvaluation}).
16160
16171
\item
@@ -16706,7 +16717,8 @@ \subsection{Conditional}
16706
16717
proceeds as follows:
16707
16718
Evaluate $e_1$ to an object $o_1$.
16708
16719
% This error can occur due to an implicit cast from \DYNAMIC.
16709
- It is a dynamic error if the run-time type of $o_1$ is not \code{bool}.
16720
+ It is a \DynamicError{dynamic error}
16721
+ if the run-time type of $o_1$ is not \code{bool}.
16710
16722
If $o_1$ is the \TRUE{} object, then the value of $c$ is
16711
16723
the result of evaluating the expression $e_2$.
16712
16724
Otherwise, the value of $c$ is the result of evaluating the expression $e_3$.
@@ -16774,23 +16786,27 @@ \subsection{Logical Boolean Expressions}
16774
16786
\code{$e_1$\,\,||\,\,$e_2$}
16775
16787
causes the evaluation of $e_1$ to an object $o_1$.
16776
16788
% This error can occur due to an implicit downcast from \DYNAMIC.
16777
- It is a dynamic error if the run-time type of $o_1$ is not \code{bool}.
16789
+ It is a \DynamicError{dynamic error}
16790
+ if the run-time type of $o_1$ is not \code{bool}.
16778
16791
If $o_1$ is \TRUE, the result of evaluating $b$ is \TRUE,
16779
16792
otherwise $e_2$ is evaluated to an object $o_2$.
16780
16793
% This error can occur due to an implicit downcast from \DYNAMIC.
16781
- It is a dynamic error if the run-time type of $o_2$ is not \code{bool}.
16794
+ It is a \DynamicError{dynamic error}
16795
+ if the run-time type of $o_2$ is not \code{bool}.
16782
16796
Otherwise the result of evaluating $b$ is $o_2$.
16783
16797
16784
16798
\LMHash{}%
16785
16799
Evaluation of a logical boolean expression $b$ of the form
16786
16800
\code{$e_1$\,\,\&\&\,\,$e_2$}
16787
16801
causes the evaluation of $e_1$ to an object $o_1$.
16788
16802
% This error can occur due to an implicit downcast from \DYNAMIC.
16789
- It is a dynamic error if the run-time type of $o_1$ is not \code{bool}.
16803
+ It is a \DynamicError{dynamic error}
16804
+ if the run-time type of $o_1$ is not \code{bool}.
16790
16805
If $o_1$ is \FALSE, the result of evaluating $b$ is \FALSE,
16791
16806
otherwise $e_2$ is evaluated to an object $o_2$.
16792
16807
% This error can occur due to an implicit downcast from \DYNAMIC.
16793
- It is a dynamic error if the run-time type of $o_2$ is not \code{bool}.
16808
+ It is a \DynamicError{dynamic error}
16809
+ if the run-time type of $o_2$ is not \code{bool}.
16794
16810
Otherwise the result of evaluating $b$ is $o_2$.
16795
16811
16796
16812
@@ -17325,7 +17341,7 @@ \subsection{Postfix Expressions}
17325
17341
17326
17342
\LMHash{}%
17327
17343
$e$ is evaluated as follows: $e_1$ is evaluated to an object $o$.
17328
- If $o$ is the null object then a dynamic error occurs,
17344
+ If $o$ is the null object then a \DynamicError{ dynamic error} occurs,
17329
17345
otherwise $e$ evaluates to $o$.
17330
17346
\EndCase
17331
17347
@@ -18655,7 +18671,7 @@ \subsection{Local Variable Declaration}
18655
18671
then $v$ is bound to $o$.
18656
18672
If an object $o$ is assigned to $v$
18657
18673
in a situation where $v$ is bound to an object $o'$
18658
- then a dynamic error occurs
18674
+ then a \DynamicError{ dynamic error} occurs
18659
18675
(\commentary{it does not matter whether $o$ is the same object as $o'$}).
18660
18676
18661
18677
\commentary{%
@@ -18816,7 +18832,8 @@ \subsection{If}
18816
18832
proceeds as follows:
18817
18833
Evaluate the expression $e$ to an object $o$.
18818
18834
% This error can occur due to an implicit downcast from \DYNAMIC.
18819
- It is a dynamic error if the run-time type of $o$ is not \code{bool}.
18835
+ It is a \DynamicError{dynamic error}
18836
+ if the run-time type of $o$ is not \code{bool}.
18820
18837
If $o$ is \TRUE, then execute the block statement $S_1$,
18821
18838
otherwise execute the block statement $S_2$.
18822
18839
@@ -18899,7 +18916,8 @@ \subsubsection{For Loop}
18899
18916
\item
18900
18917
The expression $[v'/v]c$ is evaluated to an object $o$.
18901
18918
% This error can occur due to an implicit downcast from \DYNAMIC.
18902
- It is a dynamic error if the run-time type of $o$ is not \code{bool}.
18919
+ It is a \DynamicError{dynamic error}
18920
+ if the run-time type of $o$ is not \code{bool}.
18903
18921
If $o$ is \FALSE, the for loop completes normally.
18904
18922
Otherwise, execution continues at step \ref{beginIteration}.
18905
18923
\item
@@ -19109,7 +19127,8 @@ \subsection{While}
19109
19127
\LMHash{}%
19110
19128
The expression $e$ is evaluated to an object $o$.
19111
19129
% This error can occur due to an implicit downcast from \DYNAMIC.
19112
- It is a dynamic error if the run-time type of $o$ is not \code{bool}.
19130
+ It is a \DynamicError{dynamic error}
19131
+ if the run-time type of $o$ is not \code{bool}.
19113
19132
19114
19133
\LMHash{}%
19115
19134
If $o$ is \FALSE, then execution of the while statement completes normally
@@ -19160,7 +19179,8 @@ \subsection{Do}
19160
19179
\LMHash{}%
19161
19180
Then, the expression $e$ is evaluated to an object $o$.
19162
19181
% This error can occur due to an implicit downcast from \DYNAMIC.
19163
- It is a dynamic error if the run-time type of $o$ is not \code{bool}.
19182
+ It is a \DynamicError{dynamic error}
19183
+ if the run-time type of $o$ is not \code{bool}.
19164
19184
If $o$ is \FALSE, execution of the do statement completes normally
19165
19185
(\ref{statementCompletion}).
19166
19186
If $o$ is \TRUE, then the do statement is re-executed.
@@ -19851,7 +19871,8 @@ \subsection{Return}
19851
19871
19852
19872
\LMHash{}%
19853
19873
The expression $e$ is evaluated to an object $o$.
19854
- A dynamic error occurs unless the dynamic type of $o$ is a subtype of
19874
+ A \DynamicError{dynamic error} occurs
19875
+ unless the dynamic type of $o$ is a subtype of
19855
19876
the actual return type of $f$
19856
19877
(\ref{actualTypes}).
19857
19878
Then the return statement $s$ completes returning $o$
@@ -19878,7 +19899,8 @@ \subsection{Return}
19878
19899
let \code{v} be a fresh variable bound to $o$ and
19879
19900
evaluate \code{\AWAIT{} v} to an object $r$;
19880
19901
otherwise let $r$ be $o$.
19881
- A dynamic error occurs unless the dynamic type of $r$
19902
+ A \DynamicError{dynamic error} occurs
19903
+ unless the dynamic type of $r$
19882
19904
is a subtype of the actual value of $T_v$
19883
19905
(\ref{actualTypes}).
19884
19906
Then the return statement $s$ completes returning $r$
@@ -20763,28 +20785,28 @@ \subsubsection{Semantics of Imports}
20763
20785
\NamespaceName{\metavar{import},i},
20764
20786
a corresponding function named \id{} with the same function header as $f$.
20765
20787
% This error can occur because being-loaded is a dynamic property.
20766
- Calling the function results in a dynamic error,
20788
+ Calling the function results in a \DynamicError{ dynamic error} ,
20767
20789
and so does closurizing it
20768
20790
(\ref{functionClosurization}).
20769
20791
\item
20770
20792
For every top level getter $g$ named \id{} in
20771
20793
\NamespaceName{\metavar{import},i},
20772
20794
a corresponding getter named \id{} with the same function header as $g$.
20773
20795
% This error can occur because being-loaded is a dynamic property.
20774
- Calling the getter results in a dynamic error.
20796
+ Calling the getter results in a \DynamicError{ dynamic error} .
20775
20797
\item
20776
20798
For every top level setter $s$ named \code{\id=} in
20777
20799
\NamespaceName{\metavar{import},i},
20778
20800
a corresponding setter named \code{\id=} with
20779
20801
the same function header as $s$.
20780
20802
% This error can occur because being-loaded is a dynamic property.
20781
- Calling the setter results in a dynamic error.
20803
+ Calling the setter results in a \DynamicError{ dynamic error} .
20782
20804
\item
20783
20805
For every class, mixin and type alias declaration named \id{} in
20784
20806
\NamespaceName{\metavar{import},i},
20785
20807
a corresponding getter named \id{} with return type \code{Type}.
20786
20808
% This error can occur because being-loaded is a dynamic property.
20787
- Calling the getter results in a dynamic error.
20809
+ Calling the getter results in a \DynamicError{ dynamic error} .
20788
20810
\end{itemize}
20789
20811
20790
20812
\rationale{%
@@ -21318,7 +21340,7 @@ \subsection{Scripts}
21318
21340
that spawned $i$%
21319
21341
}),
21320
21342
or the null object if no such object was supplied.
21321
- A dynamic error occurs if
21343
+ A \DynamicError{ dynamic error} occurs if
21322
21344
the run-time type of this object is not a subtype of
21323
21345
the declared type of the corresponding parameter of \code{main}.
21324
21346
\end{itemize}
@@ -21341,7 +21363,7 @@ \subsection{Scripts}
21341
21363
(\commentary{%
21342
21364
the above rules ensure that the corresponding parameters are optional%
21343
21365
}).
21344
- But the implementation must ensure that a dynamic error occurs
21366
+ But the implementation must ensure that a \DynamicError{ dynamic error} occurs
21345
21367
if an actual argument does not have a run-time type which is
21346
21368
a subtype of the declared type of the parameter.
21347
21369
0 commit comments