Skip to content

Commit 5a9fd7d

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

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}\\
@@ -60,9 +61,11 @@
6061
% - Clarify how line breaks are handled in a multi-line string literal. Rename
6162
% the lexical token NEWLINE to LINE\_BREAK (clarifying that it is not `\n`).
6263
%
63-
% Feb 2023
64+
% Jan, Feb 2023
6465
% - Change the specification of constant expressions of the form `e1 == e2`
6566
% to use primitive equality.
67+
% - Introduce `\DynamicError{}`, thus marking every introduction (definition)
68+
% of a dynamic error by a lightning symbol in the right margin.
6669
%
6770
% Dec 2022
6871
% - Change the definition of the type function 'flatten' to resolve soundness
@@ -1575,7 +1578,7 @@ \subsection{Implicitly Induced Getters and Setters}
15751578
will bind \id{} to the object that the argument $x$ is bound to.
15761579
An execution of the setter
15771580
in a situation where the variable \id{} has been bound to an object
1578-
will incur a dynamic error.
1581+
will incur a \DynamicError{dynamic error}.
15791582
\EndCase
15801583

15811584
\LMHash{}%
@@ -4158,7 +4161,7 @@ \subsubsection{Generative Constructors}
41584161
% This can occur due to a failing implicit cast.
41594162
unless the assigned object has a dynamic type
41604163
which is not a subtype of the declared type of the instance variable \id,
4161-
in which case a dynamic error occurs.
4164+
in which case a \DynamicError{dynamic error} occurs.
41624165

41634166
\commentary{%
41644167
The above rule allows initializing formals to be used as optional parameters:%
@@ -10451,7 +10454,7 @@ \subsubsection{Collection Literal Element Evaluation}
1045110454
or the given \code{value} does not have the type \code{Value},
1045210455
but it cannot occur after the pair has been appended to $s$.
1045310456
\item
10454-
Otherwise, a dynamic error occurs.
10457+
Otherwise, a \DynamicError{dynamic error} occurs.
1045510458

1045610459
\commentary{%
1045710460
This occurs when the target is an iterable respectively a map,
@@ -10506,7 +10509,8 @@ \subsubsection{Collection Literal Element Evaluation}
1050610509
and if $\ell_2$ is not present then
1050710510
$\EvaluateElement{\ell} := \LiteralSequence{}$.
1050810511
% $o_b$ can have type \DYNAMIC.
10509-
If $o_b$ is neither \TRUE{} nor \FALSE{} then a dynamic error occurs.
10512+
If $o_b$ is neither \TRUE{} nor \FALSE{}
10513+
then a \DynamicError{dynamic error} occurs.
1051010514
\EndCase
1051110515

1051210516
\LMHash{}%
@@ -10737,7 +10741,7 @@ \subsubsection{Lists}
1073710741
An empty list has an empty set of indices.
1073810742
A non-empty list has the index set $\{0, \ldots, n - 1\}$
1073910743
where $n$ is the size of the list.
10740-
It is a dynamic error to attempt to access a list
10744+
It is a \DynamicError{dynamic error} to attempt to access a list
1074110745
using an index that is not a member of its set of indices.
1074210746

1074310747
\rationale{%
@@ -10761,7 +10765,8 @@ \subsubsection{Lists}
1076110765
Only run-time list literals can be mutated
1076210766
after they are created.
1076310767
% This error can occur because being constant is a dynamic property.
10764-
Attempting to mutate a constant list literal will result in a dynamic error.
10768+
Attempting to mutate a constant list literal
10769+
will result in a \DynamicError{dynamic error}.
1076510770

1076610771
\commentary{%
1076710772
% The following is true either directly or indirectly: There is a \CONST{}
@@ -11530,7 +11535,7 @@ \subsubsection{Sets}
1153011535
\LMHash{}%
1153111536
A set may contain zero or more objects.
1153211537
Sets have a method which can be used to insert objects;
11533-
this will incur a dynamic error if the set is not modifiable.
11538+
this will incur a \DynamicError{dynamic error} if the set is not modifiable.
1153411539
Otherwise, when inserting an object $o_{\metavar{new}}$ into a set $s$,
1153511540
if an object $o_{\metavar{old}}$ exists in $s$ such that
1153611541
\code{$o_{\metavar{old}}$ == $o_{\metavar{new}}$} evaluates to \TRUE{}
@@ -11570,7 +11575,8 @@ \subsubsection{Sets}
1157011575
and it is evaluated at run time.
1157111576
Only run-time set literals can be mutated after they are created.
1157211577
% This error can occur because being constant is a dynamic property, here.
11573-
Attempting to mutate a constant set literal will result in a dynamic error.
11578+
Attempting to mutate a constant set literal
11579+
will result in a \DynamicError{dynamic error}.
1157411580

1157511581
\commentary{%
1157611582
% The following is true either directly or indirectly: There is a \CONST{}
@@ -11776,7 +11782,8 @@ \subsubsection{Maps}
1177611782
and it is evaluated at run time.
1177711783
Only run-time map literals can be mutated after they are created.
1177811784
% This error can occur because being constant is a dynamic property, here.
11779-
Attempting to mutate a constant map literal will result in a dynamic error.
11785+
Attempting to mutate a constant map literal
11786+
will result in a \DynamicError{dynamic error}.
1178011787

1178111788
\commentary{%
1178211789
% The following is true either directly or indirectly: There is a \CONST{}
@@ -11917,7 +11924,8 @@ \subsection{Throw}
1191711924
}
1191811925

1191911926
\LMHash{}%
11920-
If $v$ is the null object (\ref{null}), then a dynamic error occurs.
11927+
If $v$ is the null object (\ref{null})
11928+
then a \DynamicError{dynamic error} occurs.
1192111929
Otherwise let $t$ be a stack trace corresponding to the current execution state,
1192211930
and the \THROW{} statement throws with $v$ as exception object
1192311931
and $t$ as stack trace (\ref{expressionEvaluation}).
@@ -12437,7 +12445,7 @@ \subsubsection{New}
1243712445
% This error can occur because being-loaded is a dynamic property.
1243812446
If $T$ is a deferred type with prefix $p$,
1243912447
then if $p$ has not been successfully loaded,
12440-
a dynamic error occurs.
12448+
a \DynamicError{dynamic error} occurs.
1244112449
\EndCase
1244212450

1244312451
\LMHash{}%
@@ -13365,7 +13373,7 @@ \subsubsection{Binding Actuals to Formals}
1336513373
If $r = 0$ and $s > 0$ then
1336613374
if $f$ does not have default type arguments
1336713375
(\ref{instantiationToBound})
13368-
then a dynamic error occurs.
13376+
then a \DynamicError{dynamic error} occurs.
1336913377
Otherwise replace the actual type argument list:
1337013378
Let $r$ be $s$ and let $t_i$ for $i \in 1 .. s$ be the result of
1337113379
instantiation to bound
@@ -16388,7 +16396,8 @@ \subsection{Assignment}
1638816396
in which case $v$ has no initializer and is not definitely assigned,
1638916397
or a compile-time error would have occurred%
1639016398
}).
16391-
If $v$ has previously been bound to an object then a dynamic error occurs.
16399+
If $v$ has previously been bound to an object
16400+
then a \DynamicError{dynamic error} occurs.
1639216401
Otherwise, $v$ is bound to $o$, and then $a$ evaluates to $o$
1639316402
(\ref{expressionEvaluation}).
1639416403
\item
@@ -16940,7 +16949,8 @@ \subsection{Conditional}
1694016949
proceeds as follows:
1694116950
Evaluate $e_1$ to an object $o_1$.
1694216951
% This error can occur due to an implicit cast from \DYNAMIC.
16943-
It is a dynamic error if the run-time type of $o_1$ is not \code{bool}.
16952+
It is a \DynamicError{dynamic error}
16953+
if the run-time type of $o_1$ is not \code{bool}.
1694416954
If $o_1$ is the \TRUE{} object, then the value of $c$ is
1694516955
the result of evaluating the expression $e_2$.
1694616956
Otherwise, the value of $c$ is the result of evaluating the expression $e_3$.
@@ -17008,23 +17018,27 @@ \subsection{Logical Boolean Expressions}
1700817018
\code{$e_1$\,\,||\,\,$e_2$}
1700917019
causes the evaluation of $e_1$ to an object $o_1$.
1701017020
% This error can occur due to an implicit downcast from \DYNAMIC.
17011-
It is a dynamic error if the run-time type of $o_1$ is not \code{bool}.
17021+
It is a \DynamicError{dynamic error}
17022+
if the run-time type of $o_1$ is not \code{bool}.
1701217023
If $o_1$ is \TRUE, the result of evaluating $b$ is \TRUE,
1701317024
otherwise $e_2$ is evaluated to an object $o_2$.
1701417025
% This error can occur due to an implicit downcast from \DYNAMIC.
17015-
It is a dynamic error if the run-time type of $o_2$ is not \code{bool}.
17026+
It is a \DynamicError{dynamic error}
17027+
if the run-time type of $o_2$ is not \code{bool}.
1701617028
Otherwise the result of evaluating $b$ is $o_2$.
1701717029

1701817030
\LMHash{}%
1701917031
Evaluation of a logical boolean expression $b$ of the form
1702017032
\code{$e_1$\,\,\&\&\,\,$e_2$}
1702117033
causes the evaluation of $e_1$ to an object $o_1$.
1702217034
% This error can occur due to an implicit downcast from \DYNAMIC.
17023-
It is a dynamic error if the run-time type of $o_1$ is not \code{bool}.
17035+
It is a \DynamicError{dynamic error}
17036+
if the run-time type of $o_1$ is not \code{bool}.
1702417037
If $o_1$ is \FALSE, the result of evaluating $b$ is \FALSE,
1702517038
otherwise $e_2$ is evaluated to an object $o_2$.
1702617039
% This error can occur due to an implicit downcast from \DYNAMIC.
17027-
It is a dynamic error if the run-time type of $o_2$ is not \code{bool}.
17040+
It is a \DynamicError{dynamic error}
17041+
if the run-time type of $o_2$ is not \code{bool}.
1702817042
Otherwise the result of evaluating $b$ is $o_2$.
1702917043

1703017044

@@ -17609,7 +17623,7 @@ \subsection{Postfix Expressions}
1760917623

1761017624
\LMHash{}%
1761117625
$e$ is evaluated as follows: $e_1$ is evaluated to an object $o$.
17612-
If $o$ is the null object then a dynamic error occurs,
17626+
If $o$ is the null object then a \DynamicError{dynamic error} occurs,
1761317627
otherwise $e$ evaluates to $o$.
1761417628
\EndCase
1761517629

@@ -18937,7 +18951,7 @@ \subsection{Local Variable Declaration}
1893718951
then $v$ is bound to $o$.
1893818952
If an object $o$ is assigned to $v$
1893918953
in a situation where $v$ is bound to an object $o'$
18940-
then a dynamic error occurs
18954+
then a \DynamicError{dynamic error} occurs
1894118955
(\commentary{it does not matter whether $o$ is the same object as $o'$}).
1894218956

1894318957
\commentary{%
@@ -19098,7 +19112,8 @@ \subsection{If}
1909819112
proceeds as follows:
1909919113
Evaluate the expression $e$ to an object $o$.
1910019114
% This error can occur due to an implicit downcast from \DYNAMIC.
19101-
It is a dynamic error if the run-time type of $o$ is not \code{bool}.
19115+
It is a \DynamicError{dynamic error}
19116+
if the run-time type of $o$ is not \code{bool}.
1910219117
If $o$ is \TRUE, then execute the block statement $S_1$,
1910319118
otherwise execute the block statement $S_2$.
1910419119

@@ -19181,7 +19196,8 @@ \subsubsection{For Loop}
1918119196
\item
1918219197
The expression $[v'/v]c$ is evaluated to an object $o$.
1918319198
% This error can occur due to an implicit downcast from \DYNAMIC.
19184-
It is a dynamic error if the run-time type of $o$ is not \code{bool}.
19199+
It is a \DynamicError{dynamic error}
19200+
if the run-time type of $o$ is not \code{bool}.
1918519201
If $o$ is \FALSE, the for loop completes normally.
1918619202
Otherwise, execution continues at step \ref{beginIteration}.
1918719203
\item
@@ -19394,7 +19410,8 @@ \subsection{While}
1939419410
\LMHash{}%
1939519411
The expression $e$ is evaluated to an object $o$.
1939619412
% This error can occur due to an implicit downcast from \DYNAMIC.
19397-
It is a dynamic error if the run-time type of $o$ is not \code{bool}.
19413+
It is a \DynamicError{dynamic error}
19414+
if the run-time type of $o$ is not \code{bool}.
1939819415

1939919416
\LMHash{}%
1940019417
If $o$ is \FALSE, then execution of the while statement completes normally
@@ -19445,7 +19462,8 @@ \subsection{Do}
1944519462
\LMHash{}%
1944619463
Then, the expression $e$ is evaluated to an object $o$.
1944719464
% This error can occur due to an implicit downcast from \DYNAMIC.
19448-
It is a dynamic error if the run-time type of $o$ is not \code{bool}.
19465+
It is a \DynamicError{dynamic error}
19466+
if the run-time type of $o$ is not \code{bool}.
1944919467
If $o$ is \FALSE, execution of the do statement completes normally
1945019468
(\ref{statementCompletion}).
1945119469
If $o$ is \TRUE, then the do statement is re-executed.
@@ -20136,7 +20154,8 @@ \subsection{Return}
2013620154

2013720155
\LMHash{}%
2013820156
The expression $e$ is evaluated to an object $o$.
20139-
A dynamic error occurs unless the dynamic type of $o$ is a subtype of
20157+
A \DynamicError{dynamic error} occurs
20158+
unless the dynamic type of $o$ is a subtype of
2014020159
the actual return type of $f$
2014120160
(\ref{actualTypes}).
2014220161
Then the return statement $s$ completes returning $o$
@@ -20163,7 +20182,8 @@ \subsection{Return}
2016320182
let \code{v} be a fresh variable bound to $o$ and
2016420183
evaluate \code{\AWAIT{} v} to an object $r$;
2016520184
otherwise let $r$ be $o$.
20166-
A dynamic error occurs unless the dynamic type of $r$
20185+
A \DynamicError{dynamic error} occurs
20186+
unless the dynamic type of $r$
2016720187
is a subtype of the actual value of $T_v$
2016820188
(\ref{actualTypes}).
2016920189
Then the return statement $s$ completes returning $r$
@@ -21048,28 +21068,28 @@ \subsubsection{Semantics of Imports}
2104821068
\NamespaceName{\metavar{import},i},
2104921069
a corresponding function named \id{} with the same function header as $f$.
2105021070
% This error can occur because being-loaded is a dynamic property.
21051-
Calling the function results in a dynamic error,
21071+
Calling the function results in a \DynamicError{dynamic error},
2105221072
and so does closurizing it
2105321073
(\ref{functionClosurization}).
2105421074
\item
2105521075
For every top level getter $g$ named \id{} in
2105621076
\NamespaceName{\metavar{import},i},
2105721077
a corresponding getter named \id{} with the same function header as $g$.
2105821078
% This error can occur because being-loaded is a dynamic property.
21059-
Calling the getter results in a dynamic error.
21079+
Calling the getter results in a \DynamicError{dynamic error}.
2106021080
\item
2106121081
For every top level setter $s$ named \code{\id=} in
2106221082
\NamespaceName{\metavar{import},i},
2106321083
a corresponding setter named \code{\id=} with
2106421084
the same function header as $s$.
2106521085
% This error can occur because being-loaded is a dynamic property.
21066-
Calling the setter results in a dynamic error.
21086+
Calling the setter results in a \DynamicError{dynamic error}.
2106721087
\item
2106821088
For every class, mixin, enum, and type alias declaration named \id{} in
2106921089
\NamespaceName{\metavar{import},i},
2107021090
a corresponding getter named \id{} with return type \code{Type}.
2107121091
% This error can occur because being-loaded is a dynamic property.
21072-
Calling the getter results in a dynamic error.
21092+
Calling the getter results in a \DynamicError{dynamic error}.
2107321093
\end{itemize}
2107421094

2107521095
\rationale{%
@@ -21603,7 +21623,7 @@ \subsection{Scripts}
2160321623
that spawned $i$%
2160421624
}),
2160521625
or the null object if no such object was supplied.
21606-
A dynamic error occurs if
21626+
A \DynamicError{dynamic error} occurs if
2160721627
the run-time type of this object is not a subtype of
2160821628
the declared type of the corresponding parameter of \code{main}.
2160921629
\end{itemize}
@@ -21626,7 +21646,7 @@ \subsection{Scripts}
2162621646
(\commentary{%
2162721647
the above rules ensure that the corresponding parameters are optional%
2162821648
}).
21629-
But the implementation must ensure that a dynamic error occurs
21649+
But the implementation must ensure that a \DynamicError{dynamic error} occurs
2163021650
if an actual argument does not have a run-time type which is
2163121651
a subtype of the declared type of the parameter.
2163221652

0 commit comments

Comments
 (0)