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}\\
112
113
% error anyway; change extension names to `typeIdentifier`, avoiding
113
114
% built-in identifiers).
114
115
%
115
- % Feb 2023
116
+ % Jan, Feb 2023
116
117
% - Change the specification of constant expressions of the form `e1 == e2`
117
118
% to use primitive equality.
119
+ % - Introduce `\DynamicError{}`, thus marking every introduction (definition)
120
+ % of a dynamic error by a lightning symbol in the right margin.
118
121
%
119
122
% Dec 2022
120
123
% - Change the definition of the type function 'flatten' to resolve soundness
@@ -1631,7 +1634,7 @@ \subsection{Implicitly Induced Getters and Setters}
1631
1634
will bind \id{} to the object that the argument $x$ is bound to.
1632
1635
An execution of the setter
1633
1636
in a situation where the variable \id{} has been bound to an object
1634
- will incur a dynamic error.
1637
+ will incur a \DynamicError{ dynamic error} .
1635
1638
\EndCase
1636
1639
1637
1640
\LMHash{}%
@@ -4236,7 +4239,7 @@ \subsubsection{Generative Constructors}
4236
4239
% This can occur due to a failing implicit cast.
4237
4240
unless the assigned object has a dynamic type
4238
4241
which is not a subtype of the declared type of the instance variable \id,
4239
- in which case a dynamic error occurs.
4242
+ in which case a \DynamicError{ dynamic error} occurs.
4240
4243
4241
4244
\commentary{%
4242
4245
The above rule allows initializing formals to be used as optional parameters:%
@@ -10610,7 +10613,7 @@ \subsubsection{Collection Literal Element Evaluation}
10610
10613
or the given \code{value} does not have the type \code{Value},
10611
10614
but it cannot occur after the pair has been appended to $s$.
10612
10615
\item
10613
- Otherwise, a dynamic error occurs.
10616
+ Otherwise, a \DynamicError{ dynamic error} occurs.
10614
10617
10615
10618
\commentary{%
10616
10619
This occurs when the target is an iterable respectively a map,
@@ -10665,7 +10668,8 @@ \subsubsection{Collection Literal Element Evaluation}
10665
10668
and if $\ell_2$ is not present then
10666
10669
$\EvaluateElement{\ell} := \LiteralSequence{}$.
10667
10670
% $o_b$ can have type \DYNAMIC.
10668
- If $o_b$ is neither \TRUE{} nor \FALSE{} then a dynamic error occurs.
10671
+ If $o_b$ is neither \TRUE{} nor \FALSE{}
10672
+ then a \DynamicError{dynamic error} occurs.
10669
10673
\EndCase
10670
10674
10671
10675
\LMHash{}%
@@ -10896,7 +10900,7 @@ \subsubsection{Lists}
10896
10900
An empty list has an empty set of indices.
10897
10901
A non-empty list has the index set $\{0, \ldots, n - 1\}$
10898
10902
where $n$ is the size of the list.
10899
- It is a dynamic error to attempt to access a list
10903
+ It is a \DynamicError{ dynamic error} to attempt to access a list
10900
10904
using an index that is not a member of its set of indices.
10901
10905
10902
10906
\rationale{%
@@ -10920,7 +10924,8 @@ \subsubsection{Lists}
10920
10924
Only run-time list literals can be mutated
10921
10925
after they are created.
10922
10926
% This error can occur because being constant is a dynamic property.
10923
- Attempting to mutate a constant list literal will result in a dynamic error.
10927
+ Attempting to mutate a constant list literal
10928
+ will result in a \DynamicError{dynamic error}.
10924
10929
10925
10930
\commentary{%
10926
10931
% The following is true either directly or indirectly: There is a \CONST{}
@@ -11698,7 +11703,7 @@ \subsubsection{Sets}
11698
11703
\LMHash{}%
11699
11704
A set may contain zero or more objects.
11700
11705
Sets have a method which can be used to insert objects;
11701
- this will incur a dynamic error if the set is not modifiable.
11706
+ this will incur a \DynamicError{ dynamic error} if the set is not modifiable.
11702
11707
Otherwise, when inserting an object $o_{\metavar{new}}$ into a set $s$,
11703
11708
if an object $o_{\metavar{old}}$ exists in $s$ such that
11704
11709
\code{$o_{\metavar{old}}$ == $o_{\metavar{new}}$} evaluates to \TRUE{}
@@ -11738,7 +11743,8 @@ \subsubsection{Sets}
11738
11743
and it is evaluated at run time.
11739
11744
Only run-time set literals can be mutated after they are created.
11740
11745
% This error can occur because being constant is a dynamic property, here.
11741
- Attempting to mutate a constant set literal will result in a dynamic error.
11746
+ Attempting to mutate a constant set literal
11747
+ will result in a \DynamicError{dynamic error}.
11742
11748
11743
11749
\commentary{%
11744
11750
% The following is true either directly or indirectly: There is a \CONST{}
@@ -11946,7 +11952,8 @@ \subsubsection{Maps}
11946
11952
and it is evaluated at run time.
11947
11953
Only run-time map literals can be mutated after they are created.
11948
11954
% This error can occur because being constant is a dynamic property, here.
11949
- Attempting to mutate a constant map literal will result in a dynamic error.
11955
+ Attempting to mutate a constant map literal
11956
+ will result in a \DynamicError{dynamic error}.
11950
11957
11951
11958
\commentary{%
11952
11959
% The following is true either directly or indirectly: There is a \CONST{}
@@ -12089,7 +12096,8 @@ \subsection{Throw}
12089
12096
}
12090
12097
12091
12098
\LMHash{}%
12092
- If $v$ is the null object (\ref{null}), then a dynamic error occurs.
12099
+ If $v$ is the null object (\ref{null})
12100
+ then a \DynamicError{dynamic error} occurs.
12093
12101
Otherwise let $t$ be a stack trace corresponding to the current execution state,
12094
12102
and the \THROW{} statement throws with $v$ as exception object
12095
12103
and $t$ as stack trace (\ref{expressionEvaluation}).
@@ -12706,7 +12714,7 @@ \subsubsection{New}
12706
12714
% This error can occur because being-loaded is a dynamic property.
12707
12715
If $T$ is a deferred type with prefix $p$,
12708
12716
then if $p$ has not been successfully loaded,
12709
- a dynamic error occurs.
12717
+ a \DynamicError{ dynamic error} occurs.
12710
12718
\EndCase
12711
12719
12712
12720
\LMHash{}%
@@ -13635,7 +13643,7 @@ \subsubsection{Binding Actuals to Formals}
13635
13643
If $r = 0$ and $s > 0$ then
13636
13644
if $f$ does not have default type arguments
13637
13645
(\ref{instantiationToBound})
13638
- then a dynamic error occurs.
13646
+ then a \DynamicError{ dynamic error} occurs.
13639
13647
Otherwise replace the actual type argument list:
13640
13648
Let $r$ be $s$ and let $t_i$ for $i \in 1 .. s$ be the result of
13641
13649
instantiation to bound
@@ -16718,7 +16726,8 @@ \subsection{Assignment}
16718
16726
(in which case $v$ has no initializer and is not definitely assigned,
16719
16727
or a compile-time error would have occurred)%
16720
16728
}.
16721
- If $v$ has previously been bound to an object then a dynamic error occurs.
16729
+ If $v$ has previously been bound to an object
16730
+ then a \DynamicError{dynamic error} occurs.
16722
16731
Otherwise, $v$ is bound to $o$, and then $a$ evaluates to $o$
16723
16732
(\ref{expressionEvaluation}).
16724
16733
\item
@@ -17271,7 +17280,8 @@ \subsection{Conditional}
17271
17280
proceeds as follows:
17272
17281
Evaluate $e_1$ to an object $o_1$.
17273
17282
% This error can occur due to an implicit cast from \DYNAMIC.
17274
- It is a dynamic error if the run-time type of $o_1$ is not \code{bool}.
17283
+ It is a \DynamicError{dynamic error}
17284
+ if the run-time type of $o_1$ is not \code{bool}.
17275
17285
If $o_1$ is the \TRUE{} object, then the value of $c$ is
17276
17286
the result of evaluating the expression $e_2$.
17277
17287
Otherwise, the value of $c$ is the result of evaluating the expression $e_3$.
@@ -17339,23 +17349,27 @@ \subsection{Logical Boolean Expressions}
17339
17349
\code{$e_1$\,\,||\,\,$e_2$}
17340
17350
causes the evaluation of $e_1$ to an object $o_1$.
17341
17351
% This error can occur due to an implicit downcast from \DYNAMIC.
17342
- It is a dynamic error if the run-time type of $o_1$ is not \code{bool}.
17352
+ It is a \DynamicError{dynamic error}
17353
+ if the run-time type of $o_1$ is not \code{bool}.
17343
17354
If $o_1$ is \TRUE, the result of evaluating $b$ is \TRUE,
17344
17355
otherwise $e_2$ is evaluated to an object $o_2$.
17345
17356
% This error can occur due to an implicit downcast from \DYNAMIC.
17346
- It is a dynamic error if the run-time type of $o_2$ is not \code{bool}.
17357
+ It is a \DynamicError{dynamic error}
17358
+ if the run-time type of $o_2$ is not \code{bool}.
17347
17359
Otherwise the result of evaluating $b$ is $o_2$.
17348
17360
17349
17361
\LMHash{}%
17350
17362
Evaluation of a logical boolean expression $b$ of the form
17351
17363
\code{$e_1$\,\,\&\&\,\,$e_2$}
17352
17364
causes the evaluation of $e_1$ to an object $o_1$.
17353
17365
% This error can occur due to an implicit downcast from \DYNAMIC.
17354
- It is a dynamic error if the run-time type of $o_1$ is not \code{bool}.
17366
+ It is a \DynamicError{dynamic error}
17367
+ if the run-time type of $o_1$ is not \code{bool}.
17355
17368
If $o_1$ is \FALSE, the result of evaluating $b$ is \FALSE,
17356
17369
otherwise $e_2$ is evaluated to an object $o_2$.
17357
17370
% This error can occur due to an implicit downcast from \DYNAMIC.
17358
- It is a dynamic error if the run-time type of $o_2$ is not \code{bool}.
17371
+ It is a \DynamicError{dynamic error}
17372
+ if the run-time type of $o_2$ is not \code{bool}.
17359
17373
Otherwise the result of evaluating $b$ is $o_2$.
17360
17374
17361
17375
@@ -17951,7 +17965,7 @@ \subsection{Postfix Expressions}
17951
17965
17952
17966
\LMHash{}%
17953
17967
$e$ is evaluated as follows: $e_1$ is evaluated to an object $o$.
17954
- If $o$ is the null object then a dynamic error occurs,
17968
+ If $o$ is the null object then a \DynamicError{ dynamic error} occurs,
17955
17969
otherwise $e$ evaluates to $o$.
17956
17970
\EndCase
17957
17971
@@ -19303,7 +19317,7 @@ \subsection{Local Variable Declaration}
19303
19317
then $v$ is bound to $o$.
19304
19318
If an object $o$ is assigned to $v$
19305
19319
in a situation where $v$ is bound to an object $o'$
19306
- then a dynamic error occurs
19320
+ then a \DynamicError{ dynamic error} occurs
19307
19321
\commentary{(it does not matter whether $o$ is the same object as $o'$)}.
19308
19322
19309
19323
\commentary{%
@@ -19464,7 +19478,8 @@ \subsection{If}
19464
19478
proceeds as follows:
19465
19479
Evaluate the expression $e$ to an object $o$.
19466
19480
% This error can occur due to an implicit downcast from \DYNAMIC.
19467
- It is a dynamic error if the run-time type of $o$ is not \code{bool}.
19481
+ It is a \DynamicError{dynamic error}
19482
+ if the run-time type of $o$ is not \code{bool}.
19468
19483
If $o$ is \TRUE, then execute the block statement $S_1$,
19469
19484
otherwise execute the block statement $S_2$.
19470
19485
@@ -19550,7 +19565,8 @@ \subsubsection{For Loop}
19550
19565
\item
19551
19566
The expression $[v'/v]c$ is evaluated to an object $o$.
19552
19567
% This error can occur due to an implicit downcast from \DYNAMIC.
19553
- It is a dynamic error if the run-time type of $o$ is not \code{bool}.
19568
+ It is a \DynamicError{dynamic error}
19569
+ if the run-time type of $o$ is not \code{bool}.
19554
19570
If $o$ is \FALSE, the for loop completes normally.
19555
19571
Otherwise, execution continues at step \ref{beginIteration}.
19556
19572
\item
@@ -19763,7 +19779,8 @@ \subsection{While}
19763
19779
\LMHash{}%
19764
19780
The expression $e$ is evaluated to an object $o$.
19765
19781
% This error can occur due to an implicit downcast from \DYNAMIC.
19766
- It is a dynamic error if the run-time type of $o$ is not \code{bool}.
19782
+ It is a \DynamicError{dynamic error}
19783
+ if the run-time type of $o$ is not \code{bool}.
19767
19784
19768
19785
\LMHash{}%
19769
19786
If $o$ is \FALSE, then execution of the while statement completes normally
@@ -19814,7 +19831,8 @@ \subsection{Do}
19814
19831
\LMHash{}%
19815
19832
Then, the expression $e$ is evaluated to an object $o$.
19816
19833
% This error can occur due to an implicit downcast from \DYNAMIC.
19817
- It is a dynamic error if the run-time type of $o$ is not \code{bool}.
19834
+ It is a \DynamicError{dynamic error}
19835
+ if the run-time type of $o$ is not \code{bool}.
19818
19836
If $o$ is \FALSE, execution of the do statement completes normally
19819
19837
(\ref{statementCompletion}).
19820
19838
If $o$ is \TRUE, then the do statement is re-executed.
@@ -20572,7 +20590,8 @@ \subsection{Return}
20572
20590
20573
20591
\LMHash{}%
20574
20592
The expression $e$ is evaluated to an object $o$.
20575
- A dynamic error occurs unless the dynamic type of $o$ is a subtype of
20593
+ A \DynamicError{dynamic error} occurs
20594
+ unless the dynamic type of $o$ is a subtype of
20576
20595
the actual return type of $f$
20577
20596
(\ref{actualTypes}).
20578
20597
Then the return statement $s$ completes returning $o$
@@ -20600,7 +20619,8 @@ \subsection{Return}
20600
20619
let \code{v} be a fresh variable bound to $o$ and
20601
20620
evaluate \code{\AWAIT{} v} to an object $r$;
20602
20621
otherwise let $r$ be $o$.
20603
- A dynamic error occurs unless the dynamic type of $r$
20622
+ A \DynamicError{dynamic error} occurs
20623
+ unless the dynamic type of $r$
20604
20624
is a subtype of the actual value of $T_v$
20605
20625
(\ref{actualTypes}).
20606
20626
Then the return statement $s$ completes returning $r$
@@ -21502,21 +21522,21 @@ \subsubsection{Semantics of Imports}
21502
21522
\NamespaceName{\metavar{import},i},
21503
21523
a corresponding getter named \id{} with the same function header as $g$.
21504
21524
% This error can occur because being-loaded is a dynamic property.
21505
- Calling the getter results in a dynamic error.
21525
+ Calling the getter results in a \DynamicError{ dynamic error} .
21506
21526
\item
21507
21527
For every top level setter $s$ named \code{\id=} in
21508
21528
\NamespaceName{\metavar{import},i},
21509
21529
a corresponding setter named \code{\id=} with
21510
21530
the same function header as $s$.
21511
21531
% This error can occur because being-loaded is a dynamic property.
21512
- Calling the setter results in a dynamic error that occurs before
21513
- the actual argument is evaluated.
21532
+ Calling the setter results in a \DynamicError{ dynamic error}
21533
+ that occurs before the actual argument is evaluated.
21514
21534
\item
21515
21535
For every class, mixin, enum, and type alias declaration named \id{} in
21516
21536
\NamespaceName{\metavar{import},i},
21517
21537
a corresponding getter named \id{} with return type \code{Type}.
21518
21538
% This error can occur because being-loaded is a dynamic property.
21519
- Calling the getter results in a dynamic error.
21539
+ Calling the getter results in a \DynamicError{ dynamic error} .
21520
21540
\end{itemize}
21521
21541
21522
21542
\rationale{%
@@ -22055,7 +22075,7 @@ \subsection{Scripts}
22055
22075
that spawned $i$)%
22056
22076
},
22057
22077
or the null object if no such object was supplied.
22058
- A dynamic error occurs if
22078
+ A \DynamicError{ dynamic error} occurs if
22059
22079
the run-time type of this object is not a subtype of
22060
22080
the declared type of the corresponding parameter of \code{main}.
22061
22081
\end{itemize}
@@ -22078,7 +22098,7 @@ \subsection{Scripts}
22078
22098
\commentary{%
22079
22099
(the above rules ensure that the corresponding parameters are optional)%
22080
22100
}.
22081
- But the implementation must ensure that a dynamic error occurs
22101
+ But the implementation must ensure that a \DynamicError{ dynamic error} occurs
22082
22102
if an actual argument does not have a run-time type which is
22083
22103
a subtype of the declared type of the parameter.
22084
22104
0 commit comments