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
@@ -16226,7 +16234,8 @@ \subsection{Assignment}
16226
16234
in which case $v$ has no initializer and is not definitely assigned,
16227
16235
or a compile-time error would have occurred%
16228
16236
}).
16229
- If $v$ has previously been bound to an object then a dynamic error occurs.
16237
+ If $v$ has previously been bound to an object
16238
+ then a \DynamicError{dynamic error} occurs.
16230
16239
Otherwise, $v$ is bound to $o$, and then $a$ evaluates to $o$
16231
16240
(\ref{expressionEvaluation}).
16232
16241
\item
@@ -16778,7 +16787,8 @@ \subsection{Conditional}
16778
16787
proceeds as follows:
16779
16788
Evaluate $e_1$ to an object $o_1$.
16780
16789
% This error can occur due to an implicit cast from \DYNAMIC.
16781
- It is a dynamic error if the run-time type of $o_1$ is not \code{bool}.
16790
+ It is a \DynamicError{dynamic error}
16791
+ if the run-time type of $o_1$ is not \code{bool}.
16782
16792
If $o_1$ is the \TRUE{} object, then the value of $c$ is
16783
16793
the result of evaluating the expression $e_2$.
16784
16794
Otherwise, the value of $c$ is the result of evaluating the expression $e_3$.
@@ -16846,23 +16856,27 @@ \subsection{Logical Boolean Expressions}
16846
16856
\code{$e_1$\,\,||\,\,$e_2$}
16847
16857
causes the evaluation of $e_1$ to an object $o_1$.
16848
16858
% This error can occur due to an implicit downcast from \DYNAMIC.
16849
- It is a dynamic error if the run-time type of $o_1$ is not \code{bool}.
16859
+ It is a \DynamicError{dynamic error}
16860
+ if the run-time type of $o_1$ is not \code{bool}.
16850
16861
If $o_1$ is \TRUE, the result of evaluating $b$ is \TRUE,
16851
16862
otherwise $e_2$ is evaluated to an object $o_2$.
16852
16863
% This error can occur due to an implicit downcast from \DYNAMIC.
16853
- It is a dynamic error if the run-time type of $o_2$ is not \code{bool}.
16864
+ It is a \DynamicError{dynamic error}
16865
+ if the run-time type of $o_2$ is not \code{bool}.
16854
16866
Otherwise the result of evaluating $b$ is $o_2$.
16855
16867
16856
16868
\LMHash{}%
16857
16869
Evaluation of a logical boolean expression $b$ of the form
16858
16870
\code{$e_1$\,\,\&\&\,\,$e_2$}
16859
16871
causes the evaluation of $e_1$ to an object $o_1$.
16860
16872
% This error can occur due to an implicit downcast from \DYNAMIC.
16861
- It is a dynamic error if the run-time type of $o_1$ is not \code{bool}.
16873
+ It is a \DynamicError{dynamic error}
16874
+ if the run-time type of $o_1$ is not \code{bool}.
16862
16875
If $o_1$ is \FALSE, the result of evaluating $b$ is \FALSE,
16863
16876
otherwise $e_2$ is evaluated to an object $o_2$.
16864
16877
% This error can occur due to an implicit downcast from \DYNAMIC.
16865
- It is a dynamic error if the run-time type of $o_2$ is not \code{bool}.
16878
+ It is a \DynamicError{dynamic error}
16879
+ if the run-time type of $o_2$ is not \code{bool}.
16866
16880
Otherwise the result of evaluating $b$ is $o_2$.
16867
16881
16868
16882
@@ -17447,7 +17461,7 @@ \subsection{Postfix Expressions}
17447
17461
17448
17462
\LMHash{}%
17449
17463
$e$ is evaluated as follows: $e_1$ is evaluated to an object $o$.
17450
- If $o$ is the null object then a dynamic error occurs,
17464
+ If $o$ is the null object then a \DynamicError{ dynamic error} occurs,
17451
17465
otherwise $e$ evaluates to $o$.
17452
17466
\EndCase
17453
17467
@@ -18777,7 +18791,7 @@ \subsection{Local Variable Declaration}
18777
18791
then $v$ is bound to $o$.
18778
18792
If an object $o$ is assigned to $v$
18779
18793
in a situation where $v$ is bound to an object $o'$
18780
- then a dynamic error occurs
18794
+ then a \DynamicError{ dynamic error} occurs
18781
18795
(\commentary{it does not matter whether $o$ is the same object as $o'$}).
18782
18796
18783
18797
\commentary{%
@@ -18938,7 +18952,8 @@ \subsection{If}
18938
18952
proceeds as follows:
18939
18953
Evaluate the expression $e$ to an object $o$.
18940
18954
% This error can occur due to an implicit downcast from \DYNAMIC.
18941
- It is a dynamic error if the run-time type of $o$ is not \code{bool}.
18955
+ It is a \DynamicError{dynamic error}
18956
+ if the run-time type of $o$ is not \code{bool}.
18942
18957
If $o$ is \TRUE, then execute the block statement $S_1$,
18943
18958
otherwise execute the block statement $S_2$.
18944
18959
@@ -19021,7 +19036,8 @@ \subsubsection{For Loop}
19021
19036
\item
19022
19037
The expression $[v'/v]c$ is evaluated to an object $o$.
19023
19038
% This error can occur due to an implicit downcast from \DYNAMIC.
19024
- It is a dynamic error if the run-time type of $o$ is not \code{bool}.
19039
+ It is a \DynamicError{dynamic error}
19040
+ if the run-time type of $o$ is not \code{bool}.
19025
19041
If $o$ is \FALSE, the for loop completes normally.
19026
19042
Otherwise, execution continues at step \ref{beginIteration}.
19027
19043
\item
@@ -19231,7 +19247,8 @@ \subsection{While}
19231
19247
\LMHash{}%
19232
19248
The expression $e$ is evaluated to an object $o$.
19233
19249
% This error can occur due to an implicit downcast from \DYNAMIC.
19234
- It is a dynamic error if the run-time type of $o$ is not \code{bool}.
19250
+ It is a \DynamicError{dynamic error}
19251
+ if the run-time type of $o$ is not \code{bool}.
19235
19252
19236
19253
\LMHash{}%
19237
19254
If $o$ is \FALSE, then execution of the while statement completes normally
@@ -19282,7 +19299,8 @@ \subsection{Do}
19282
19299
\LMHash{}%
19283
19300
Then, the expression $e$ is evaluated to an object $o$.
19284
19301
% This error can occur due to an implicit downcast from \DYNAMIC.
19285
- It is a dynamic error if the run-time type of $o$ is not \code{bool}.
19302
+ It is a \DynamicError{dynamic error}
19303
+ if the run-time type of $o$ is not \code{bool}.
19286
19304
If $o$ is \FALSE, execution of the do statement completes normally
19287
19305
(\ref{statementCompletion}).
19288
19306
If $o$ is \TRUE, then the do statement is re-executed.
@@ -19973,7 +19991,8 @@ \subsection{Return}
19973
19991
19974
19992
\LMHash{}%
19975
19993
The expression $e$ is evaluated to an object $o$.
19976
- A dynamic error occurs unless the dynamic type of $o$ is a subtype of
19994
+ A \DynamicError{dynamic error} occurs
19995
+ unless the dynamic type of $o$ is a subtype of
19977
19996
the actual return type of $f$
19978
19997
(\ref{actualTypes}).
19979
19998
Then the return statement $s$ completes returning $o$
@@ -20000,7 +20019,8 @@ \subsection{Return}
20000
20019
let \code{v} be a fresh variable bound to $o$ and
20001
20020
evaluate \code{\AWAIT{} v} to an object $r$;
20002
20021
otherwise let $r$ be $o$.
20003
- A dynamic error occurs unless the dynamic type of $r$
20022
+ A \DynamicError{dynamic error} occurs
20023
+ unless the dynamic type of $r$
20004
20024
is a subtype of the actual value of $T_v$
20005
20025
(\ref{actualTypes}).
20006
20026
Then the return statement $s$ completes returning $r$
@@ -20885,28 +20905,28 @@ \subsubsection{Semantics of Imports}
20885
20905
\NamespaceName{\metavar{import},i},
20886
20906
a corresponding function named \id{} with the same function header as $f$.
20887
20907
% This error can occur because being-loaded is a dynamic property.
20888
- Calling the function results in a dynamic error,
20908
+ Calling the function results in a \DynamicError{ dynamic error} ,
20889
20909
and so does closurizing it
20890
20910
(\ref{functionClosurization}).
20891
20911
\item
20892
20912
For every top level getter $g$ named \id{} in
20893
20913
\NamespaceName{\metavar{import},i},
20894
20914
a corresponding getter named \id{} with the same function header as $g$.
20895
20915
% This error can occur because being-loaded is a dynamic property.
20896
- Calling the getter results in a dynamic error.
20916
+ Calling the getter results in a \DynamicError{ dynamic error} .
20897
20917
\item
20898
20918
For every top level setter $s$ named \code{\id=} in
20899
20919
\NamespaceName{\metavar{import},i},
20900
20920
a corresponding setter named \code{\id=} with
20901
20921
the same function header as $s$.
20902
20922
% This error can occur because being-loaded is a dynamic property.
20903
- Calling the setter results in a dynamic error.
20923
+ Calling the setter results in a \DynamicError{ dynamic error} .
20904
20924
\item
20905
20925
For every class, mixin and type alias declaration named \id{} in
20906
20926
\NamespaceName{\metavar{import},i},
20907
20927
a corresponding getter named \id{} with return type \code{Type}.
20908
20928
% This error can occur because being-loaded is a dynamic property.
20909
- Calling the getter results in a dynamic error.
20929
+ Calling the getter results in a \DynamicError{ dynamic error} .
20910
20930
\end{itemize}
20911
20931
20912
20932
\rationale{%
@@ -21440,7 +21460,7 @@ \subsection{Scripts}
21440
21460
that spawned $i$%
21441
21461
}),
21442
21462
or the null object if no such object was supplied.
21443
- A dynamic error occurs if
21463
+ A \DynamicError{ dynamic error} occurs if
21444
21464
the run-time type of this object is not a subtype of
21445
21465
the declared type of the corresponding parameter of \code{main}.
21446
21466
\end{itemize}
@@ -21463,7 +21483,7 @@ \subsection{Scripts}
21463
21483
(\commentary{%
21464
21484
the above rules ensure that the corresponding parameters are optional%
21465
21485
}).
21466
- But the implementation must ensure that a dynamic error occurs
21486
+ But the implementation must ensure that a \DynamicError{ dynamic error} occurs
21467
21487
if an actual argument does not have a run-time type which is
21468
21488
a subtype of the declared type of the parameter.
21469
21489
0 commit comments