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}\\
40
41
% - Clarify how line breaks are handled in a multi-line string literal. Rename
41
42
% the lexical token NEWLINE to LINE\_BREAK (clarifying that it is not `\n`).
42
43
%
43
- % Feb 2023
44
+ % Jan, Feb 2023
44
45
% - Change the specification of constant expressions of the form `e1 == e2`
45
46
% to use primitive equality.
47
+ % - Introduce `\DynamicError{}`, thus marking every introduction (definition)
48
+ % of a dynamic error by a lightning symbol in the right margin.
46
49
%
47
50
% Dec 2022
48
51
% - Change the definition of the type function 'flatten' to resolve soundness
@@ -1472,7 +1475,7 @@ \subsection{Implicitly Induced Getters and Setters}
1472
1475
it will bind \id{} to the object that $x$ is bound to.
1473
1476
If this setter is executed
1474
1477
in a situation where the variable \id{} has been bound to an object,
1475
- a dynamic error occurs.
1478
+ a \DynamicError{ dynamic error} occurs.
1476
1479
1477
1480
\commentary{%
1478
1481
A late final variable declaration with no initializer is permitted.
@@ -1513,7 +1516,7 @@ \subsection{Implicitly Induced Getters and Setters}
1513
1516
will bind \id{} to the object that the argument $x$ is bound to.
1514
1517
An execution of the setter
1515
1518
in a situation where the variable \id{} has been bound to an object
1516
- will incur a dynamic error.
1519
+ will incur a \DynamicError{ dynamic error} .
1517
1520
1518
1521
\LMHash{}%
1519
1522
The scope into which the implicit getters and setters are introduced
@@ -1567,7 +1570,7 @@ \subsection{Implicitly Induced Getters and Setters}
1567
1570
but initialization and assignment is not the same thing.
1568
1571
When the receiver has type \DYNAMIC{}
1569
1572
such an assignment is not a compile-time error,
1570
- but if there is no such setter it will cause a dynamic error.%
1573
+ but if there is no such setter it will cause a \DynamicError{ dynamic error} .%
1571
1574
}
1572
1575
1573
1576
\LMHash{}%
@@ -1689,7 +1692,7 @@ \subsection{Evaluation of Implicit Variable Getters}
1689
1692
will evaluate to the object that \id{} is bound to.
1690
1693
Otherwise
1691
1694
(\commentary{when this variable has never been bound}),
1692
- the getter invocation incurs a dynamic error.
1695
+ the getter invocation incurs a \DynamicError{ dynamic error} .
1693
1696
\EndCase
1694
1697
1695
1698
\LMHash{}%
@@ -1796,7 +1799,7 @@ \subsection{Evaluation of Implicit Variable Getters}
1796
1799
will complete returning $o$.
1797
1800
An execution of the implicitly induced getter of \id{}
1798
1801
in a situation where the variable \id{} is unbound
1799
- will incur a dynamic error.
1802
+ will incur a \DynamicError{ dynamic error} .
1800
1803
\end{itemize}
1801
1804
1802
1805
% Reduce whitespace after itemized list: This is just an end symbol.
@@ -4004,7 +4007,7 @@ \subsubsection{Generative Constructors}
4004
4007
% This can occur due to a failing implicit cast.
4005
4008
unless the assigned object has a dynamic type
4006
4009
which is not a subtype of the declared type of the instance variable \id,
4007
- in which case a dynamic error occurs.
4010
+ in which case a \DynamicError{ dynamic error} occurs.
4008
4011
4009
4012
\commentary{%
4010
4013
The above rule allows initializing formals to be used as optional parameters:%
@@ -10295,7 +10298,7 @@ \subsubsection{Collection Literal Element Evaluation}
10295
10298
or the given \code{value} does not have the type \code{Value},
10296
10299
but it cannot occur after the pair has been appended to $s$.
10297
10300
\item
10298
- Otherwise, a dynamic error occurs.
10301
+ Otherwise, a \DynamicError{ dynamic error} occurs.
10299
10302
10300
10303
\commentary{%
10301
10304
This occurs when the target is an iterable respectively a map,
@@ -10350,7 +10353,8 @@ \subsubsection{Collection Literal Element Evaluation}
10350
10353
and if $\ell_2$ is not present then
10351
10354
$\EvaluateElement{\ell} := \LiteralSequence{}$.
10352
10355
% $o_b$ can have type \DYNAMIC.
10353
- If $o_b$ is neither \TRUE{} nor \FALSE{} then a dynamic error occurs.
10356
+ If $o_b$ is neither \TRUE{} nor \FALSE{}
10357
+ then a \DynamicError{dynamic error} occurs.
10354
10358
\EndCase
10355
10359
10356
10360
\LMHash{}%
@@ -10581,7 +10585,7 @@ \subsubsection{Lists}
10581
10585
An empty list has an empty set of indices.
10582
10586
A non-empty list has the index set $\{0, \ldots, n - 1\}$
10583
10587
where $n$ is the size of the list.
10584
- It is a dynamic error to attempt to access a list
10588
+ It is a \DynamicError{ dynamic error} to attempt to access a list
10585
10589
using an index that is not a member of its set of indices.
10586
10590
10587
10591
\rationale{%
@@ -10605,7 +10609,8 @@ \subsubsection{Lists}
10605
10609
Only run-time list literals can be mutated
10606
10610
after they are created.
10607
10611
% This error can occur because being constant is a dynamic property.
10608
- Attempting to mutate a constant list literal will result in a dynamic error.
10612
+ Attempting to mutate a constant list literal
10613
+ will result in a \DynamicError{dynamic error}.
10609
10614
10610
10615
\commentary{%
10611
10616
% The following is true either directly or indirectly: There is a \CONST{}
@@ -11374,7 +11379,7 @@ \subsubsection{Sets}
11374
11379
\LMHash{}%
11375
11380
A set may contain zero or more objects.
11376
11381
Sets have a method which can be used to insert objects;
11377
- this will incur a dynamic error if the set is not modifiable.
11382
+ this will incur a \DynamicError{ dynamic error} if the set is not modifiable.
11378
11383
Otherwise, when inserting an object $o_{\metavar{new}}$ into a set $s$,
11379
11384
if an object $o_{\metavar{old}}$ exists in $s$ such that
11380
11385
\code{$o_{\metavar{old}}$ == $o_{\metavar{new}}$} evaluates to \TRUE{}
@@ -11414,7 +11419,8 @@ \subsubsection{Sets}
11414
11419
and it is evaluated at run time.
11415
11420
Only run-time set literals can be mutated after they are created.
11416
11421
% This error can occur because being constant is a dynamic property, here.
11417
- Attempting to mutate a constant set literal will result in a dynamic error.
11422
+ Attempting to mutate a constant set literal
11423
+ will result in a \DynamicError{dynamic error}.
11418
11424
11419
11425
\commentary{%
11420
11426
% The following is true either directly or indirectly: There is a \CONST{}
@@ -11620,7 +11626,8 @@ \subsubsection{Maps}
11620
11626
and it is evaluated at run time.
11621
11627
Only run-time map literals can be mutated after they are created.
11622
11628
% This error can occur because being constant is a dynamic property, here.
11623
- Attempting to mutate a constant map literal will result in a dynamic error.
11629
+ Attempting to mutate a constant map literal
11630
+ will result in a \DynamicError{dynamic error}.
11624
11631
11625
11632
\commentary{%
11626
11633
% The following is true either directly or indirectly: There is a \CONST{}
@@ -11761,7 +11768,8 @@ \subsection{Throw}
11761
11768
}
11762
11769
11763
11770
\LMHash{}%
11764
- If $v$ is the null object (\ref{null}), then a dynamic error occurs.
11771
+ If $v$ is the null object (\ref{null})
11772
+ then a \DynamicError{dynamic error} occurs.
11765
11773
Otherwise let $t$ be a stack trace corresponding to the current execution state,
11766
11774
and the \THROW{} statement throws with $v$ as exception object
11767
11775
and $t$ as stack trace (\ref{expressionEvaluation}).
@@ -12275,7 +12283,7 @@ \subsubsection{New}
12275
12283
% This error can occur because being-loaded is a dynamic property.
12276
12284
If $T$ is a deferred type with prefix $p$,
12277
12285
then if $p$ has not been successfully loaded,
12278
- a dynamic error occurs.
12286
+ a \DynamicError{ dynamic error} occurs.
12279
12287
\EndCase
12280
12288
12281
12289
\LMHash{}%
@@ -13203,7 +13211,7 @@ \subsubsection{Binding Actuals to Formals}
13203
13211
If $r = 0$ and $s > 0$ then
13204
13212
if $f$ does not have default type arguments
13205
13213
(\ref{instantiationToBound})
13206
- then a dynamic error occurs.
13214
+ then a \DynamicError{ dynamic error} occurs.
13207
13215
Otherwise replace the actual type argument list:
13208
13216
Let $r$ be $s$ and let $t_i$ for $i \in 1 .. s$ be the result of
13209
13217
instantiation to bound
@@ -16168,7 +16176,8 @@ \subsection{Assignment}
16168
16176
in which case $v$ has no initializer and is not definitely assigned,
16169
16177
or a compile-time error would have occurred%
16170
16178
}).
16171
- If $v$ has previously been bound to an object then a dynamic error occurs.
16179
+ If $v$ has previously been bound to an object
16180
+ then a \DynamicError{dynamic error} occurs.
16172
16181
Otherwise, $v$ is bound to $o$, and then $a$ evaluates to $o$
16173
16182
(\ref{expressionEvaluation}).
16174
16183
\item
@@ -16720,7 +16729,8 @@ \subsection{Conditional}
16720
16729
proceeds as follows:
16721
16730
Evaluate $e_1$ to an object $o_1$.
16722
16731
% This error can occur due to an implicit cast from \DYNAMIC.
16723
- It is a dynamic error if the run-time type of $o_1$ is not \code{bool}.
16732
+ It is a \DynamicError{dynamic error}
16733
+ if the run-time type of $o_1$ is not \code{bool}.
16724
16734
If $o_1$ is the \TRUE{} object, then the value of $c$ is
16725
16735
the result of evaluating the expression $e_2$.
16726
16736
Otherwise, the value of $c$ is the result of evaluating the expression $e_3$.
@@ -16788,23 +16798,27 @@ \subsection{Logical Boolean Expressions}
16788
16798
\code{$e_1$\,\,||\,\,$e_2$}
16789
16799
causes the evaluation of $e_1$ to an object $o_1$.
16790
16800
% This error can occur due to an implicit downcast from \DYNAMIC.
16791
- It is a dynamic error if the run-time type of $o_1$ is not \code{bool}.
16801
+ It is a \DynamicError{dynamic error}
16802
+ if the run-time type of $o_1$ is not \code{bool}.
16792
16803
If $o_1$ is \TRUE, the result of evaluating $b$ is \TRUE,
16793
16804
otherwise $e_2$ is evaluated to an object $o_2$.
16794
16805
% This error can occur due to an implicit downcast from \DYNAMIC.
16795
- It is a dynamic error if the run-time type of $o_2$ is not \code{bool}.
16806
+ It is a \DynamicError{dynamic error}
16807
+ if the run-time type of $o_2$ is not \code{bool}.
16796
16808
Otherwise the result of evaluating $b$ is $o_2$.
16797
16809
16798
16810
\LMHash{}%
16799
16811
Evaluation of a logical boolean expression $b$ of the form
16800
16812
\code{$e_1$\,\,\&\&\,\,$e_2$}
16801
16813
causes the evaluation of $e_1$ to an object $o_1$.
16802
16814
% This error can occur due to an implicit downcast from \DYNAMIC.
16803
- It is a dynamic error if the run-time type of $o_1$ is not \code{bool}.
16815
+ It is a \DynamicError{dynamic error}
16816
+ if the run-time type of $o_1$ is not \code{bool}.
16804
16817
If $o_1$ is \FALSE, the result of evaluating $b$ is \FALSE,
16805
16818
otherwise $e_2$ is evaluated to an object $o_2$.
16806
16819
% This error can occur due to an implicit downcast from \DYNAMIC.
16807
- It is a dynamic error if the run-time type of $o_2$ is not \code{bool}.
16820
+ It is a \DynamicError{dynamic error}
16821
+ if the run-time type of $o_2$ is not \code{bool}.
16808
16822
Otherwise the result of evaluating $b$ is $o_2$.
16809
16823
16810
16824
@@ -17339,7 +17353,7 @@ \subsection{Postfix Expressions}
17339
17353
17340
17354
\LMHash{}%
17341
17355
$e$ is evaluated as follows: $e_1$ is evaluated to an object $o$.
17342
- If $o$ is the null object then a dynamic error occurs,
17356
+ If $o$ is the null object then a \DynamicError{ dynamic error} occurs,
17343
17357
otherwise $e$ evaluates to $o$.
17344
17358
\EndCase
17345
17359
@@ -18669,7 +18683,7 @@ \subsection{Local Variable Declaration}
18669
18683
then $v$ is bound to $o$.
18670
18684
If an object $o$ is assigned to $v$
18671
18685
in a situation where $v$ is bound to an object $o'$
18672
- then a dynamic error occurs
18686
+ then a \DynamicError{ dynamic error} occurs
18673
18687
(\commentary{it does not matter whether $o$ is the same object as $o'$}).
18674
18688
18675
18689
\commentary{%
@@ -18830,7 +18844,8 @@ \subsection{If}
18830
18844
proceeds as follows:
18831
18845
Evaluate the expression $e$ to an object $o$.
18832
18846
% This error can occur due to an implicit downcast from \DYNAMIC.
18833
- It is a dynamic error if the run-time type of $o$ is not \code{bool}.
18847
+ It is a \DynamicError{dynamic error}
18848
+ if the run-time type of $o$ is not \code{bool}.
18834
18849
If $o$ is \TRUE, then execute the block statement $S_1$,
18835
18850
otherwise execute the block statement $S_2$.
18836
18851
@@ -18913,7 +18928,8 @@ \subsubsection{For Loop}
18913
18928
\item
18914
18929
The expression $[v'/v]c$ is evaluated to an object $o$.
18915
18930
% This error can occur due to an implicit downcast from \DYNAMIC.
18916
- It is a dynamic error if the run-time type of $o$ is not \code{bool}.
18931
+ It is a \DynamicError{dynamic error}
18932
+ if the run-time type of $o$ is not \code{bool}.
18917
18933
If $o$ is \FALSE, the for loop completes normally.
18918
18934
Otherwise, execution continues at step \ref{beginIteration}.
18919
18935
\item
@@ -19123,7 +19139,8 @@ \subsection{While}
19123
19139
\LMHash{}%
19124
19140
The expression $e$ is evaluated to an object $o$.
19125
19141
% This error can occur due to an implicit downcast from \DYNAMIC.
19126
- It is a dynamic error if the run-time type of $o$ is not \code{bool}.
19142
+ It is a \DynamicError{dynamic error}
19143
+ if the run-time type of $o$ is not \code{bool}.
19127
19144
19128
19145
\LMHash{}%
19129
19146
If $o$ is \FALSE, then execution of the while statement completes normally
@@ -19174,7 +19191,8 @@ \subsection{Do}
19174
19191
\LMHash{}%
19175
19192
Then, the expression $e$ is evaluated to an object $o$.
19176
19193
% This error can occur due to an implicit downcast from \DYNAMIC.
19177
- It is a dynamic error if the run-time type of $o$ is not \code{bool}.
19194
+ It is a \DynamicError{dynamic error}
19195
+ if the run-time type of $o$ is not \code{bool}.
19178
19196
If $o$ is \FALSE, execution of the do statement completes normally
19179
19197
(\ref{statementCompletion}).
19180
19198
If $o$ is \TRUE, then the do statement is re-executed.
@@ -19865,7 +19883,8 @@ \subsection{Return}
19865
19883
19866
19884
\LMHash{}%
19867
19885
The expression $e$ is evaluated to an object $o$.
19868
- A dynamic error occurs unless the dynamic type of $o$ is a subtype of
19886
+ A \DynamicError{dynamic error} occurs
19887
+ unless the dynamic type of $o$ is a subtype of
19869
19888
the actual return type of $f$
19870
19889
(\ref{actualTypes}).
19871
19890
Then the return statement $s$ completes returning $o$
@@ -19892,7 +19911,8 @@ \subsection{Return}
19892
19911
let \code{v} be a fresh variable bound to $o$ and
19893
19912
evaluate \code{\AWAIT{} v} to an object $r$;
19894
19913
otherwise let $r$ be $o$.
19895
- A dynamic error occurs unless the dynamic type of $r$
19914
+ A \DynamicError{dynamic error} occurs
19915
+ unless the dynamic type of $r$
19896
19916
is a subtype of the actual value of $T_v$
19897
19917
(\ref{actualTypes}).
19898
19918
Then the return statement $s$ completes returning $r$
@@ -20777,28 +20797,28 @@ \subsubsection{Semantics of Imports}
20777
20797
\NamespaceName{\metavar{import},i},
20778
20798
a corresponding function named \id{} with the same function header as $f$.
20779
20799
% This error can occur because being-loaded is a dynamic property.
20780
- Calling the function results in a dynamic error,
20800
+ Calling the function results in a \DynamicError{ dynamic error} ,
20781
20801
and so does closurizing it
20782
20802
(\ref{functionClosurization}).
20783
20803
\item
20784
20804
For every top level getter $g$ named \id{} in
20785
20805
\NamespaceName{\metavar{import},i},
20786
20806
a corresponding getter named \id{} with the same function header as $g$.
20787
20807
% This error can occur because being-loaded is a dynamic property.
20788
- Calling the getter results in a dynamic error.
20808
+ Calling the getter results in a \DynamicError{ dynamic error} .
20789
20809
\item
20790
20810
For every top level setter $s$ named \code{\id=} in
20791
20811
\NamespaceName{\metavar{import},i},
20792
20812
a corresponding setter named \code{\id=} with
20793
20813
the same function header as $s$.
20794
20814
% This error can occur because being-loaded is a dynamic property.
20795
- Calling the setter results in a dynamic error.
20815
+ Calling the setter results in a \DynamicError{ dynamic error} .
20796
20816
\item
20797
20817
For every class, mixin and type alias declaration named \id{} in
20798
20818
\NamespaceName{\metavar{import},i},
20799
20819
a corresponding getter named \id{} with return type \code{Type}.
20800
20820
% This error can occur because being-loaded is a dynamic property.
20801
- Calling the getter results in a dynamic error.
20821
+ Calling the getter results in a \DynamicError{ dynamic error} .
20802
20822
\end{itemize}
20803
20823
20804
20824
\rationale{%
@@ -21332,7 +21352,7 @@ \subsection{Scripts}
21332
21352
that spawned $i$%
21333
21353
}),
21334
21354
or the null object if no such object was supplied.
21335
- A dynamic error occurs if
21355
+ A \DynamicError{ dynamic error} occurs if
21336
21356
the run-time type of this object is not a subtype of
21337
21357
the declared type of the corresponding parameter of \code{main}.
21338
21358
\end{itemize}
@@ -21355,7 +21375,7 @@ \subsection{Scripts}
21355
21375
(\commentary{%
21356
21376
the above rules ensure that the corresponding parameters are optional%
21357
21377
}).
21358
- But the implementation must ensure that a dynamic error occurs
21378
+ But the implementation must ensure that a \DynamicError{ dynamic error} occurs
21359
21379
if an actual argument does not have a run-time type which is
21360
21380
a subtype of the declared type of the parameter.
21361
21381
0 commit comments