Skip to content

Commit aeba266

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

File tree

2 files changed

+64
-40
lines changed

2 files changed

+64
-40
lines changed

specification/dart.sty

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

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

174174
% Used for the defining occurrence of a local symbol.
175175
\newcommand{\DefineSymbol}[1]{%
@@ -190,11 +190,15 @@
190190

191191
% Same appearance, but not adding an entry to the index.
192192
\newcommand{\NoIndex}[1]{%
193-
\leavevmode\marginpar{\ensuremath{_{^\vartriangle}}}\emph{#1}}
193+
\leavevmode\marginpar{\ensuremath{\vartriangle}}\emph{#1}}
194194

195195
% Mark a compile-time error in the margin.
196196
\newcommand{\Error}[1]{%
197-
\leavevmode\marginpar{\ensuremath{_{^\ominus}}}{#1}}
197+
\leavevmode\marginpar{\ensuremath{\ominus}}{#1}}
198+
199+
% Mark a dynamic error in the margin.
200+
\newcommand{\DynamicError}[1]{%
201+
\leavevmode\marginpar{\Lightning}{#1}}
198202

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

specification/dartLangSpec.tex

Lines changed: 57 additions & 37 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}\\
@@ -40,9 +41,11 @@
4041
% - Clarify how line breaks are handled in a multi-line string literal. Rename
4142
% the lexical token NEWLINE to LINE\_BREAK (clarifying that it is not `\n`).
4243
%
43-
% Feb 2023
44+
% Jan, Feb 2023
4445
% - Change the specification of constant expressions of the form `e1 == e2`
4546
% 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.
4649
%
4750
% Dec 2022
4851
% - Change the definition of the type function 'flatten' to resolve soundness
@@ -1472,7 +1475,7 @@ \subsection{Implicitly Induced Getters and Setters}
14721475
it will bind \id{} to the object that $x$ is bound to.
14731476
If this setter is executed
14741477
in a situation where the variable \id{} has been bound to an object,
1475-
a dynamic error occurs.
1478+
a \DynamicError{dynamic error} occurs.
14761479

14771480
\commentary{%
14781481
A late final variable declaration with no initializer is permitted.
@@ -1513,7 +1516,7 @@ \subsection{Implicitly Induced Getters and Setters}
15131516
will bind \id{} to the object that the argument $x$ is bound to.
15141517
An execution of the setter
15151518
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}.
15171520

15181521
\LMHash{}%
15191522
The scope into which the implicit getters and setters are introduced
@@ -1567,7 +1570,7 @@ \subsection{Implicitly Induced Getters and Setters}
15671570
but initialization and assignment is not the same thing.
15681571
When the receiver has type \DYNAMIC{}
15691572
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}.%
15711574
}
15721575

15731576
\LMHash{}%
@@ -1689,7 +1692,7 @@ \subsection{Evaluation of Implicit Variable Getters}
16891692
will evaluate to the object that \id{} is bound to.
16901693
Otherwise
16911694
(\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}.
16931696
\EndCase
16941697

16951698
\LMHash{}%
@@ -1796,7 +1799,7 @@ \subsection{Evaluation of Implicit Variable Getters}
17961799
will complete returning $o$.
17971800
An execution of the implicitly induced getter of \id{}
17981801
in a situation where the variable \id{} is unbound
1799-
will incur a dynamic error.
1802+
will incur a \DynamicError{dynamic error}.
18001803
\end{itemize}
18011804

18021805
% Reduce whitespace after itemized list: This is just an end symbol.
@@ -4004,7 +4007,7 @@ \subsubsection{Generative Constructors}
40044007
% This can occur due to a failing implicit cast.
40054008
unless the assigned object has a dynamic type
40064009
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.
40084011

40094012
\commentary{%
40104013
The above rule allows initializing formals to be used as optional parameters:%
@@ -10295,7 +10298,7 @@ \subsubsection{Collection Literal Element Evaluation}
1029510298
or the given \code{value} does not have the type \code{Value},
1029610299
but it cannot occur after the pair has been appended to $s$.
1029710300
\item
10298-
Otherwise, a dynamic error occurs.
10301+
Otherwise, a \DynamicError{dynamic error} occurs.
1029910302

1030010303
\commentary{%
1030110304
This occurs when the target is an iterable respectively a map,
@@ -10350,7 +10353,8 @@ \subsubsection{Collection Literal Element Evaluation}
1035010353
and if $\ell_2$ is not present then
1035110354
$\EvaluateElement{\ell} := \LiteralSequence{}$.
1035210355
% $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.
1035410358
\EndCase
1035510359

1035610360
\LMHash{}%
@@ -10581,7 +10585,7 @@ \subsubsection{Lists}
1058110585
An empty list has an empty set of indices.
1058210586
A non-empty list has the index set $\{0, \ldots, n - 1\}$
1058310587
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
1058510589
using an index that is not a member of its set of indices.
1058610590

1058710591
\rationale{%
@@ -10605,7 +10609,8 @@ \subsubsection{Lists}
1060510609
Only run-time list literals can be mutated
1060610610
after they are created.
1060710611
% 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}.
1060910614

1061010615
\commentary{%
1061110616
% The following is true either directly or indirectly: There is a \CONST{}
@@ -11374,7 +11379,7 @@ \subsubsection{Sets}
1137411379
\LMHash{}%
1137511380
A set may contain zero or more objects.
1137611381
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.
1137811383
Otherwise, when inserting an object $o_{\metavar{new}}$ into a set $s$,
1137911384
if an object $o_{\metavar{old}}$ exists in $s$ such that
1138011385
\code{$o_{\metavar{old}}$ == $o_{\metavar{new}}$} evaluates to \TRUE{}
@@ -11414,7 +11419,8 @@ \subsubsection{Sets}
1141411419
and it is evaluated at run time.
1141511420
Only run-time set literals can be mutated after they are created.
1141611421
% 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}.
1141811424

1141911425
\commentary{%
1142011426
% The following is true either directly or indirectly: There is a \CONST{}
@@ -11620,7 +11626,8 @@ \subsubsection{Maps}
1162011626
and it is evaluated at run time.
1162111627
Only run-time map literals can be mutated after they are created.
1162211628
% 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}.
1162411631

1162511632
\commentary{%
1162611633
% The following is true either directly or indirectly: There is a \CONST{}
@@ -11761,7 +11768,8 @@ \subsection{Throw}
1176111768
}
1176211769

1176311770
\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.
1176511773
Otherwise let $t$ be a stack trace corresponding to the current execution state,
1176611774
and the \THROW{} statement throws with $v$ as exception object
1176711775
and $t$ as stack trace (\ref{expressionEvaluation}).
@@ -12275,7 +12283,7 @@ \subsubsection{New}
1227512283
% This error can occur because being-loaded is a dynamic property.
1227612284
If $T$ is a deferred type with prefix $p$,
1227712285
then if $p$ has not been successfully loaded,
12278-
a dynamic error occurs.
12286+
a \DynamicError{dynamic error} occurs.
1227912287
\EndCase
1228012288

1228112289
\LMHash{}%
@@ -13203,7 +13211,7 @@ \subsubsection{Binding Actuals to Formals}
1320313211
If $r = 0$ and $s > 0$ then
1320413212
if $f$ does not have default type arguments
1320513213
(\ref{instantiationToBound})
13206-
then a dynamic error occurs.
13214+
then a \DynamicError{dynamic error} occurs.
1320713215
Otherwise replace the actual type argument list:
1320813216
Let $r$ be $s$ and let $t_i$ for $i \in 1 .. s$ be the result of
1320913217
instantiation to bound
@@ -16226,7 +16234,8 @@ \subsection{Assignment}
1622616234
in which case $v$ has no initializer and is not definitely assigned,
1622716235
or a compile-time error would have occurred%
1622816236
}).
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.
1623016239
Otherwise, $v$ is bound to $o$, and then $a$ evaluates to $o$
1623116240
(\ref{expressionEvaluation}).
1623216241
\item
@@ -16778,7 +16787,8 @@ \subsection{Conditional}
1677816787
proceeds as follows:
1677916788
Evaluate $e_1$ to an object $o_1$.
1678016789
% 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}.
1678216792
If $o_1$ is the \TRUE{} object, then the value of $c$ is
1678316793
the result of evaluating the expression $e_2$.
1678416794
Otherwise, the value of $c$ is the result of evaluating the expression $e_3$.
@@ -16846,23 +16856,27 @@ \subsection{Logical Boolean Expressions}
1684616856
\code{$e_1$\,\,||\,\,$e_2$}
1684716857
causes the evaluation of $e_1$ to an object $o_1$.
1684816858
% 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}.
1685016861
If $o_1$ is \TRUE, the result of evaluating $b$ is \TRUE,
1685116862
otherwise $e_2$ is evaluated to an object $o_2$.
1685216863
% 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}.
1685416866
Otherwise the result of evaluating $b$ is $o_2$.
1685516867

1685616868
\LMHash{}%
1685716869
Evaluation of a logical boolean expression $b$ of the form
1685816870
\code{$e_1$\,\,\&\&\,\,$e_2$}
1685916871
causes the evaluation of $e_1$ to an object $o_1$.
1686016872
% 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}.
1686216875
If $o_1$ is \FALSE, the result of evaluating $b$ is \FALSE,
1686316876
otherwise $e_2$ is evaluated to an object $o_2$.
1686416877
% 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}.
1686616880
Otherwise the result of evaluating $b$ is $o_2$.
1686716881

1686816882

@@ -17447,7 +17461,7 @@ \subsection{Postfix Expressions}
1744717461

1744817462
\LMHash{}%
1744917463
$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,
1745117465
otherwise $e$ evaluates to $o$.
1745217466
\EndCase
1745317467

@@ -18777,7 +18791,7 @@ \subsection{Local Variable Declaration}
1877718791
then $v$ is bound to $o$.
1877818792
If an object $o$ is assigned to $v$
1877918793
in a situation where $v$ is bound to an object $o'$
18780-
then a dynamic error occurs
18794+
then a \DynamicError{dynamic error} occurs
1878118795
(\commentary{it does not matter whether $o$ is the same object as $o'$}).
1878218796

1878318797
\commentary{%
@@ -18938,7 +18952,8 @@ \subsection{If}
1893818952
proceeds as follows:
1893918953
Evaluate the expression $e$ to an object $o$.
1894018954
% 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}.
1894218957
If $o$ is \TRUE, then execute the block statement $S_1$,
1894318958
otherwise execute the block statement $S_2$.
1894418959

@@ -19021,7 +19036,8 @@ \subsubsection{For Loop}
1902119036
\item
1902219037
The expression $[v'/v]c$ is evaluated to an object $o$.
1902319038
% 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}.
1902519041
If $o$ is \FALSE, the for loop completes normally.
1902619042
Otherwise, execution continues at step \ref{beginIteration}.
1902719043
\item
@@ -19231,7 +19247,8 @@ \subsection{While}
1923119247
\LMHash{}%
1923219248
The expression $e$ is evaluated to an object $o$.
1923319249
% 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}.
1923519252

1923619253
\LMHash{}%
1923719254
If $o$ is \FALSE, then execution of the while statement completes normally
@@ -19282,7 +19299,8 @@ \subsection{Do}
1928219299
\LMHash{}%
1928319300
Then, the expression $e$ is evaluated to an object $o$.
1928419301
% 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}.
1928619304
If $o$ is \FALSE, execution of the do statement completes normally
1928719305
(\ref{statementCompletion}).
1928819306
If $o$ is \TRUE, then the do statement is re-executed.
@@ -19973,7 +19991,8 @@ \subsection{Return}
1997319991

1997419992
\LMHash{}%
1997519993
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
1997719996
the actual return type of $f$
1997819997
(\ref{actualTypes}).
1997919998
Then the return statement $s$ completes returning $o$
@@ -20000,7 +20019,8 @@ \subsection{Return}
2000020019
let \code{v} be a fresh variable bound to $o$ and
2000120020
evaluate \code{\AWAIT{} v} to an object $r$;
2000220021
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$
2000420024
is a subtype of the actual value of $T_v$
2000520025
(\ref{actualTypes}).
2000620026
Then the return statement $s$ completes returning $r$
@@ -20885,28 +20905,28 @@ \subsubsection{Semantics of Imports}
2088520905
\NamespaceName{\metavar{import},i},
2088620906
a corresponding function named \id{} with the same function header as $f$.
2088720907
% 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},
2088920909
and so does closurizing it
2089020910
(\ref{functionClosurization}).
2089120911
\item
2089220912
For every top level getter $g$ named \id{} in
2089320913
\NamespaceName{\metavar{import},i},
2089420914
a corresponding getter named \id{} with the same function header as $g$.
2089520915
% 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}.
2089720917
\item
2089820918
For every top level setter $s$ named \code{\id=} in
2089920919
\NamespaceName{\metavar{import},i},
2090020920
a corresponding setter named \code{\id=} with
2090120921
the same function header as $s$.
2090220922
% 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}.
2090420924
\item
2090520925
For every class, mixin and type alias declaration named \id{} in
2090620926
\NamespaceName{\metavar{import},i},
2090720927
a corresponding getter named \id{} with return type \code{Type}.
2090820928
% 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}.
2091020930
\end{itemize}
2091120931

2091220932
\rationale{%
@@ -21440,7 +21460,7 @@ \subsection{Scripts}
2144021460
that spawned $i$%
2144121461
}),
2144221462
or the null object if no such object was supplied.
21443-
A dynamic error occurs if
21463+
A \DynamicError{dynamic error} occurs if
2144421464
the run-time type of this object is not a subtype of
2144521465
the declared type of the corresponding parameter of \code{main}.
2144621466
\end{itemize}
@@ -21463,7 +21483,7 @@ \subsection{Scripts}
2146321483
(\commentary{%
2146421484
the above rules ensure that the corresponding parameters are optional%
2146521485
}).
21466-
But the implementation must ensure that a dynamic error occurs
21486+
But the implementation must ensure that a \DynamicError{dynamic error} occurs
2146721487
if an actual argument does not have a run-time type which is
2146821488
a subtype of the declared type of the parameter.
2146921489

0 commit comments

Comments
 (0)