Skip to content

Commit af211be

Browse files
committed
Introduce \DynamicError, marking all dynamic errors just like compile-time errors have been for a while
1 parent 2acf467 commit af211be

File tree

2 files changed

+60
-36
lines changed

2 files changed

+60
-36
lines changed

specification/dart.sty

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@
174174

175175
% Used for defining occurrence of phrase, with customized index entry.
176176
\newcommand{\IndexCustom}[2]{%
177-
\leavevmode\marginpar{\ensuremath{_{^\vartriangle}}}\emph{#1}\index{#2}}
177+
\leavevmode\marginpar{\ensuremath{\vartriangle}}\emph{#1}\index{#2}}
178178

179179
% Used for the defining occurrence of a local symbol.
180180
\newcommand{\DefineSymbol}[1]{%
@@ -195,11 +195,15 @@
195195

196196
% Same appearance, but not adding an entry to the index.
197197
\newcommand{\NoIndex}[1]{%
198-
\leavevmode\marginpar{\ensuremath{_{^\vartriangle}}}\emph{#1}}
198+
\leavevmode\marginpar{\ensuremath{\vartriangle}}\emph{#1}}
199199

200200
% Mark a compile-time error in the margin.
201201
\newcommand{\Error}[1]{%
202-
\leavevmode\marginpar{\ensuremath{_{^\ominus}}}{#1}}
202+
\leavevmode\marginpar{\ensuremath{\ominus}}{#1}}
203+
204+
% Mark a dynamic error in the margin.
205+
\newcommand{\DynamicError}[1]{%
206+
\leavevmode\marginpar{\Lightning}{#1}}
203207

204208
% Used to specify comma separated lists of similar symbols.
205209
\newcommand{\List}[3]{\ensuremath{{#1}_{#2},\,\ldots,\ {#1}_{#3}}}

specification/dartLangSpec.tex

Lines changed: 53 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
\usepackage[T1]{fontenc}
1313
\usepackage{makeidx}
1414
\usepackage{enumitem}
15+
\usepackage{marvosym}
1516
\makeindex
1617
\title{Dart Programming Language Specification\\
1718
{6th edition draft}\\
@@ -70,9 +71,11 @@
7071
% error anyway; change extension names to `typeIdentifier`, avoiding
7172
% built-in identifiers).
7273
%
73-
% Feb 2023
74+
% Jan, Feb 2023
7475
% - Change the specification of constant expressions of the form `e1 == e2`
7576
% to use primitive equality.
77+
% - Introduce `\DynamicError{}`, thus marking every introduction (definition)
78+
% of a dynamic error by a lightning symbol in the right margin.
7679
%
7780
% Dec 2022
7881
% - Change the definition of the type function 'flatten' to resolve soundness
@@ -1585,7 +1588,7 @@ \subsection{Implicitly Induced Getters and Setters}
15851588
will bind \id{} to the object that the argument $x$ is bound to.
15861589
An execution of the setter
15871590
in a situation where the variable \id{} has been bound to an object
1588-
will incur a dynamic error.
1591+
will incur a \DynamicError{dynamic error}.
15891592
\EndCase
15901593

15911594
\LMHash{}%
@@ -4178,7 +4181,7 @@ \subsubsection{Generative Constructors}
41784181
% This can occur due to a failing implicit cast.
41794182
unless the assigned object has a dynamic type
41804183
which is not a subtype of the declared type of the instance variable \id,
4181-
in which case a dynamic error occurs.
4184+
in which case a \DynamicError{dynamic error} occurs.
41824185

41834186
\commentary{%
41844187
The above rule allows initializing formals to be used as optional parameters:%
@@ -10469,7 +10472,7 @@ \subsubsection{Collection Literal Element Evaluation}
1046910472
or the given \code{value} does not have the type \code{Value},
1047010473
but it cannot occur after the pair has been appended to $s$.
1047110474
\item
10472-
Otherwise, a dynamic error occurs.
10475+
Otherwise, a \DynamicError{dynamic error} occurs.
1047310476

1047410477
\commentary{%
1047510478
This occurs when the target is an iterable respectively a map,
@@ -10524,7 +10527,8 @@ \subsubsection{Collection Literal Element Evaluation}
1052410527
and if $\ell_2$ is not present then
1052510528
$\EvaluateElement{\ell} := \LiteralSequence{}$.
1052610529
% $o_b$ can have type \DYNAMIC.
10527-
If $o_b$ is neither \TRUE{} nor \FALSE{} then a dynamic error occurs.
10530+
If $o_b$ is neither \TRUE{} nor \FALSE{}
10531+
then a \DynamicError{dynamic error} occurs.
1052810532
\EndCase
1052910533

1053010534
\LMHash{}%
@@ -10755,7 +10759,7 @@ \subsubsection{Lists}
1075510759
An empty list has an empty set of indices.
1075610760
A non-empty list has the index set $\{0, \ldots, n - 1\}$
1075710761
where $n$ is the size of the list.
10758-
It is a dynamic error to attempt to access a list
10762+
It is a \DynamicError{dynamic error} to attempt to access a list
1075910763
using an index that is not a member of its set of indices.
1076010764

1076110765
\rationale{%
@@ -10779,7 +10783,8 @@ \subsubsection{Lists}
1077910783
Only run-time list literals can be mutated
1078010784
after they are created.
1078110785
% This error can occur because being constant is a dynamic property.
10782-
Attempting to mutate a constant list literal will result in a dynamic error.
10786+
Attempting to mutate a constant list literal
10787+
will result in a \DynamicError{dynamic error}.
1078310788

1078410789
\commentary{%
1078510790
% The following is true either directly or indirectly: There is a \CONST{}
@@ -11548,7 +11553,7 @@ \subsubsection{Sets}
1154811553
\LMHash{}%
1154911554
A set may contain zero or more objects.
1155011555
Sets have a method which can be used to insert objects;
11551-
this will incur a dynamic error if the set is not modifiable.
11556+
this will incur a \DynamicError{dynamic error} if the set is not modifiable.
1155211557
Otherwise, when inserting an object $o_{\metavar{new}}$ into a set $s$,
1155311558
if an object $o_{\metavar{old}}$ exists in $s$ such that
1155411559
\code{$o_{\metavar{old}}$ == $o_{\metavar{new}}$} evaluates to \TRUE{}
@@ -11588,7 +11593,8 @@ \subsubsection{Sets}
1158811593
and it is evaluated at run time.
1158911594
Only run-time set literals can be mutated after they are created.
1159011595
% This error can occur because being constant is a dynamic property, here.
11591-
Attempting to mutate a constant set literal will result in a dynamic error.
11596+
Attempting to mutate a constant set literal
11597+
will result in a \DynamicError{dynamic error}.
1159211598

1159311599
\commentary{%
1159411600
% The following is true either directly or indirectly: There is a \CONST{}
@@ -11794,7 +11800,8 @@ \subsubsection{Maps}
1179411800
and it is evaluated at run time.
1179511801
Only run-time map literals can be mutated after they are created.
1179611802
% This error can occur because being constant is a dynamic property, here.
11797-
Attempting to mutate a constant map literal will result in a dynamic error.
11803+
Attempting to mutate a constant map literal
11804+
will result in a \DynamicError{dynamic error}.
1179811805

1179911806
\commentary{%
1180011807
% The following is true either directly or indirectly: There is a \CONST{}
@@ -11935,7 +11942,8 @@ \subsection{Throw}
1193511942
}
1193611943

1193711944
\LMHash{}%
11938-
If $v$ is the null object (\ref{null}), then a dynamic error occurs.
11945+
If $v$ is the null object (\ref{null})
11946+
then a \DynamicError{dynamic error} occurs.
1193911947
Otherwise let $t$ be a stack trace corresponding to the current execution state,
1194011948
and the \THROW{} statement throws with $v$ as exception object
1194111949
and $t$ as stack trace (\ref{expressionEvaluation}).
@@ -12455,7 +12463,7 @@ \subsubsection{New}
1245512463
% This error can occur because being-loaded is a dynamic property.
1245612464
If $T$ is a deferred type with prefix $p$,
1245712465
then if $p$ has not been successfully loaded,
12458-
a dynamic error occurs.
12466+
a \DynamicError{dynamic error} occurs.
1245912467
\EndCase
1246012468

1246112469
\LMHash{}%
@@ -13384,7 +13392,7 @@ \subsubsection{Binding Actuals to Formals}
1338413392
If $r = 0$ and $s > 0$ then
1338513393
if $f$ does not have default type arguments
1338613394
(\ref{instantiationToBound})
13387-
then a dynamic error occurs.
13395+
then a \DynamicError{dynamic error} occurs.
1338813396
Otherwise replace the actual type argument list:
1338913397
Let $r$ be $s$ and let $t_i$ for $i \in 1 .. s$ be the result of
1339013398
instantiation to bound
@@ -16407,7 +16415,8 @@ \subsection{Assignment}
1640716415
in which case $v$ has no initializer and is not definitely assigned,
1640816416
or a compile-time error would have occurred%
1640916417
}).
16410-
If $v$ has previously been bound to an object then a dynamic error occurs.
16418+
If $v$ has previously been bound to an object
16419+
then a \DynamicError{dynamic error} occurs.
1641116420
Otherwise, $v$ is bound to $o$, and then $a$ evaluates to $o$
1641216421
(\ref{expressionEvaluation}).
1641316422
\item
@@ -16959,7 +16968,8 @@ \subsection{Conditional}
1695916968
proceeds as follows:
1696016969
Evaluate $e_1$ to an object $o_1$.
1696116970
% This error can occur due to an implicit cast from \DYNAMIC.
16962-
It is a dynamic error if the run-time type of $o_1$ is not \code{bool}.
16971+
It is a \DynamicError{dynamic error}
16972+
if the run-time type of $o_1$ is not \code{bool}.
1696316973
If $o_1$ is the \TRUE{} object, then the value of $c$ is
1696416974
the result of evaluating the expression $e_2$.
1696516975
Otherwise, the value of $c$ is the result of evaluating the expression $e_3$.
@@ -17027,23 +17037,27 @@ \subsection{Logical Boolean Expressions}
1702717037
\code{$e_1$\,\,||\,\,$e_2$}
1702817038
causes the evaluation of $e_1$ to an object $o_1$.
1702917039
% This error can occur due to an implicit downcast from \DYNAMIC.
17030-
It is a dynamic error if the run-time type of $o_1$ is not \code{bool}.
17040+
It is a \DynamicError{dynamic error}
17041+
if the run-time type of $o_1$ is not \code{bool}.
1703117042
If $o_1$ is \TRUE, the result of evaluating $b$ is \TRUE,
1703217043
otherwise $e_2$ is evaluated to an object $o_2$.
1703317044
% This error can occur due to an implicit downcast from \DYNAMIC.
17034-
It is a dynamic error if the run-time type of $o_2$ is not \code{bool}.
17045+
It is a \DynamicError{dynamic error}
17046+
if the run-time type of $o_2$ is not \code{bool}.
1703517047
Otherwise the result of evaluating $b$ is $o_2$.
1703617048

1703717049
\LMHash{}%
1703817050
Evaluation of a logical boolean expression $b$ of the form
1703917051
\code{$e_1$\,\,\&\&\,\,$e_2$}
1704017052
causes the evaluation of $e_1$ to an object $o_1$.
1704117053
% This error can occur due to an implicit downcast from \DYNAMIC.
17042-
It is a dynamic error if the run-time type of $o_1$ is not \code{bool}.
17054+
It is a \DynamicError{dynamic error}
17055+
if the run-time type of $o_1$ is not \code{bool}.
1704317056
If $o_1$ is \FALSE, the result of evaluating $b$ is \FALSE,
1704417057
otherwise $e_2$ is evaluated to an object $o_2$.
1704517058
% This error can occur due to an implicit downcast from \DYNAMIC.
17046-
It is a dynamic error if the run-time type of $o_2$ is not \code{bool}.
17059+
It is a \DynamicError{dynamic error}
17060+
if the run-time type of $o_2$ is not \code{bool}.
1704717061
Otherwise the result of evaluating $b$ is $o_2$.
1704817062

1704917063

@@ -17628,7 +17642,7 @@ \subsection{Postfix Expressions}
1762817642

1762917643
\LMHash{}%
1763017644
$e$ is evaluated as follows: $e_1$ is evaluated to an object $o$.
17631-
If $o$ is the null object then a dynamic error occurs,
17645+
If $o$ is the null object then a \DynamicError{dynamic error} occurs,
1763217646
otherwise $e$ evaluates to $o$.
1763317647
\EndCase
1763417648

@@ -18960,7 +18974,7 @@ \subsection{Local Variable Declaration}
1896018974
then $v$ is bound to $o$.
1896118975
If an object $o$ is assigned to $v$
1896218976
in a situation where $v$ is bound to an object $o'$
18963-
then a dynamic error occurs
18977+
then a \DynamicError{dynamic error} occurs
1896418978
(\commentary{it does not matter whether $o$ is the same object as $o'$}).
1896518979

1896618980
\commentary{%
@@ -19121,7 +19135,8 @@ \subsection{If}
1912119135
proceeds as follows:
1912219136
Evaluate the expression $e$ to an object $o$.
1912319137
% This error can occur due to an implicit downcast from \DYNAMIC.
19124-
It is a dynamic error if the run-time type of $o$ is not \code{bool}.
19138+
It is a \DynamicError{dynamic error}
19139+
if the run-time type of $o$ is not \code{bool}.
1912519140
If $o$ is \TRUE, then execute the block statement $S_1$,
1912619141
otherwise execute the block statement $S_2$.
1912719142

@@ -19204,7 +19219,8 @@ \subsubsection{For Loop}
1920419219
\item
1920519220
The expression $[v'/v]c$ is evaluated to an object $o$.
1920619221
% This error can occur due to an implicit downcast from \DYNAMIC.
19207-
It is a dynamic error if the run-time type of $o$ is not \code{bool}.
19222+
It is a \DynamicError{dynamic error}
19223+
if the run-time type of $o$ is not \code{bool}.
1920819224
If $o$ is \FALSE, the for loop completes normally.
1920919225
Otherwise, execution continues at step \ref{beginIteration}.
1921019226
\item
@@ -19417,7 +19433,8 @@ \subsection{While}
1941719433
\LMHash{}%
1941819434
The expression $e$ is evaluated to an object $o$.
1941919435
% This error can occur due to an implicit downcast from \DYNAMIC.
19420-
It is a dynamic error if the run-time type of $o$ is not \code{bool}.
19436+
It is a \DynamicError{dynamic error}
19437+
if the run-time type of $o$ is not \code{bool}.
1942119438

1942219439
\LMHash{}%
1942319440
If $o$ is \FALSE, then execution of the while statement completes normally
@@ -19468,7 +19485,8 @@ \subsection{Do}
1946819485
\LMHash{}%
1946919486
Then, the expression $e$ is evaluated to an object $o$.
1947019487
% This error can occur due to an implicit downcast from \DYNAMIC.
19471-
It is a dynamic error if the run-time type of $o$ is not \code{bool}.
19488+
It is a \DynamicError{dynamic error}
19489+
if the run-time type of $o$ is not \code{bool}.
1947219490
If $o$ is \FALSE, execution of the do statement completes normally
1947319491
(\ref{statementCompletion}).
1947419492
If $o$ is \TRUE, then the do statement is re-executed.
@@ -20159,7 +20177,8 @@ \subsection{Return}
2015920177

2016020178
\LMHash{}%
2016120179
The expression $e$ is evaluated to an object $o$.
20162-
A dynamic error occurs unless the dynamic type of $o$ is a subtype of
20180+
A \DynamicError{dynamic error} occurs
20181+
unless the dynamic type of $o$ is a subtype of
2016320182
the actual return type of $f$
2016420183
(\ref{actualTypes}).
2016520184
Then the return statement $s$ completes returning $o$
@@ -20186,7 +20205,8 @@ \subsection{Return}
2018620205
let \code{v} be a fresh variable bound to $o$ and
2018720206
evaluate \code{\AWAIT{} v} to an object $r$;
2018820207
otherwise let $r$ be $o$.
20189-
A dynamic error occurs unless the dynamic type of $r$
20208+
A \DynamicError{dynamic error} occurs
20209+
unless the dynamic type of $r$
2019020210
is a subtype of the actual value of $T_v$
2019120211
(\ref{actualTypes}).
2019220212
Then the return statement $s$ completes returning $r$
@@ -21073,28 +21093,28 @@ \subsubsection{Semantics of Imports}
2107321093
\NamespaceName{\metavar{import},i},
2107421094
a corresponding function named \id{} with the same function header as $f$.
2107521095
% This error can occur because being-loaded is a dynamic property.
21076-
Calling the function results in a dynamic error,
21096+
Calling the function results in a \DynamicError{dynamic error},
2107721097
and so does closurizing it
2107821098
(\ref{functionClosurization}).
2107921099
\item
2108021100
For every top level getter $g$ named \id{} in
2108121101
\NamespaceName{\metavar{import},i},
2108221102
a corresponding getter named \id{} with the same function header as $g$.
2108321103
% This error can occur because being-loaded is a dynamic property.
21084-
Calling the getter results in a dynamic error.
21104+
Calling the getter results in a \DynamicError{dynamic error}.
2108521105
\item
2108621106
For every top level setter $s$ named \code{\id=} in
2108721107
\NamespaceName{\metavar{import},i},
2108821108
a corresponding setter named \code{\id=} with
2108921109
the same function header as $s$.
2109021110
% This error can occur because being-loaded is a dynamic property.
21091-
Calling the setter results in a dynamic error.
21111+
Calling the setter results in a \DynamicError{dynamic error}.
2109221112
\item
2109321113
For every class, mixin, enum, and type alias declaration named \id{} in
2109421114
\NamespaceName{\metavar{import},i},
2109521115
a corresponding getter named \id{} with return type \code{Type}.
2109621116
% This error can occur because being-loaded is a dynamic property.
21097-
Calling the getter results in a dynamic error.
21117+
Calling the getter results in a \DynamicError{dynamic error}.
2109821118
\end{itemize}
2109921119

2110021120
\rationale{%
@@ -21628,7 +21648,7 @@ \subsection{Scripts}
2162821648
that spawned $i$%
2162921649
}),
2163021650
or the null object if no such object was supplied.
21631-
A dynamic error occurs if
21651+
A \DynamicError{dynamic error} occurs if
2163221652
the run-time type of this object is not a subtype of
2163321653
the declared type of the corresponding parameter of \code{main}.
2163421654
\end{itemize}
@@ -21651,7 +21671,7 @@ \subsection{Scripts}
2165121671
(\commentary{%
2165221672
the above rules ensure that the corresponding parameters are optional%
2165321673
}).
21654-
But the implementation must ensure that a dynamic error occurs
21674+
But the implementation must ensure that a \DynamicError{dynamic error} occurs
2165521675
if an actual argument does not have a run-time type which is
2165621676
a subtype of the declared type of the parameter.
2165721677

0 commit comments

Comments
 (0)