Skip to content

Commit 9b4f226

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

File tree

2 files changed

+65
-39
lines changed

2 files changed

+65
-39
lines changed

specification/dart.sty

+7-3
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

+58-36
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}\\
@@ -36,6 +37,10 @@
3637
% version of the language which will actually be specified by the next stable
3738
% release of this document.
3839
%
40+
% Jan, Feb 2023
41+
% - Introduce `\DynamicError{}`, thus marking every introduction (definition)
42+
% of a dynamic error by a lightning symbol in the right margin.
43+
%
3944
% Dec 2022
4045
% - Change the definition of the type function 'flatten' to resolve soundness
4146
% issue, cf. SDK issue #49396.
@@ -1464,7 +1469,7 @@ \subsection{Implicitly Induced Getters and Setters}
14641469
it will bind \id{} to the object that $x$ is bound to.
14651470
If this setter is executed
14661471
in a situation where the variable \id{} has been bound to an object,
1467-
a dynamic error occurs.
1472+
a \DynamicError{dynamic error} occurs.
14681473

14691474
\commentary{%
14701475
A late final variable declaration with no initializer is permitted.
@@ -1505,7 +1510,7 @@ \subsection{Implicitly Induced Getters and Setters}
15051510
will bind \id{} to the object that the argument $x$ is bound to.
15061511
An execution of the setter
15071512
in a situation where the variable \id{} has been bound to an object
1508-
will incur a dynamic error.
1513+
will incur a \DynamicError{dynamic error}.
15091514

15101515
\LMHash{}%
15111516
The scope into which the implicit getters and setters are introduced
@@ -1559,7 +1564,7 @@ \subsection{Implicitly Induced Getters and Setters}
15591564
but initialization and assignment is not the same thing.
15601565
When the receiver has type \DYNAMIC{}
15611566
such an assignment is not a compile-time error,
1562-
but if there is no such setter it will cause a dynamic error.%
1567+
but if there is no such setter it will cause a \DynamicError{dynamic error}.%
15631568
}
15641569

15651570
\LMHash{}%
@@ -1681,7 +1686,7 @@ \subsection{Evaluation of Implicit Variable Getters}
16811686
will evaluate to the object that \id{} is bound to.
16821687
Otherwise
16831688
(\commentary{when this variable has never been bound}),
1684-
the getter invocation incurs a dynamic error.
1689+
the getter invocation incurs a \DynamicError{dynamic error}.
16851690
\EndCase
16861691

16871692
\LMHash{}%
@@ -1788,7 +1793,7 @@ \subsection{Evaluation of Implicit Variable Getters}
17881793
will complete returning $o$.
17891794
An execution of the implicitly induced getter of \id{}
17901795
in a situation where the variable \id{} is unbound
1791-
will incur a dynamic error.
1796+
will incur a \DynamicError{dynamic error}.
17921797
\end{itemize}
17931798

17941799
% Reduce whitespace after itemized list: This is just an end symbol.
@@ -3996,7 +4001,7 @@ \subsubsection{Generative Constructors}
39964001
% This can occur due to a failing implicit cast.
39974002
unless the assigned object has a dynamic type
39984003
which is not a subtype of the declared type of the instance variable \id,
3999-
in which case a dynamic error occurs.
4004+
in which case a \DynamicError{dynamic error} occurs.
40004005

40014006
\commentary{%
40024007
The above rule allows initializing formals to be used as optional parameters:%
@@ -10281,7 +10286,7 @@ \subsubsection{Collection Literal Element Evaluation}
1028110286
or the given \code{value} does not have the type \code{Value},
1028210287
but it cannot occur after the pair has been appended to $s$.
1028310288
\item
10284-
Otherwise, a dynamic error occurs.
10289+
Otherwise, a \DynamicError{dynamic error} occurs.
1028510290

1028610291
\commentary{%
1028710292
This occurs when the target is an iterable respectively a map,
@@ -10336,7 +10341,8 @@ \subsubsection{Collection Literal Element Evaluation}
1033610341
and if $\ell_2$ is not present then
1033710342
$\EvaluateElement{\ell} := \LiteralSequence{}$.
1033810343
% $o_b$ can have type \DYNAMIC.
10339-
If $o_b$ is neither \TRUE{} nor \FALSE{} then a dynamic error occurs.
10344+
If $o_b$ is neither \TRUE{} nor \FALSE{}
10345+
then a \DynamicError{dynamic error} occurs.
1034010346
\EndCase
1034110347

1034210348
\LMHash{}%
@@ -10567,7 +10573,7 @@ \subsubsection{Lists}
1056710573
An empty list has an empty set of indices.
1056810574
A non-empty list has the index set $\{0, \ldots, n - 1\}$
1056910575
where $n$ is the size of the list.
10570-
It is a dynamic error to attempt to access a list
10576+
It is a \DynamicError{dynamic error} to attempt to access a list
1057110577
using an index that is not a member of its set of indices.
1057210578

1057310579
\rationale{%
@@ -10591,7 +10597,8 @@ \subsubsection{Lists}
1059110597
Only run-time list literals can be mutated
1059210598
after they are created.
1059310599
% This error can occur because being constant is a dynamic property.
10594-
Attempting to mutate a constant list literal will result in a dynamic error.
10600+
Attempting to mutate a constant list literal
10601+
will result in a \DynamicError{dynamic error}.
1059510602

1059610603
\commentary{%
1059710604
% The following is true either directly or indirectly: There is a \CONST{}
@@ -11360,7 +11367,7 @@ \subsubsection{Sets}
1136011367
\LMHash{}%
1136111368
A set may contain zero or more objects.
1136211369
Sets have a method which can be used to insert objects;
11363-
this will incur a dynamic error if the set is not modifiable.
11370+
this will incur a \DynamicError{dynamic error} if the set is not modifiable.
1136411371
Otherwise, when inserting an object $o_{\metavar{new}}$ into a set $s$,
1136511372
if an object $o_{\metavar{old}}$ exists in $s$ such that
1136611373
\code{$o_{\metavar{old}}$ == $o_{\metavar{new}}$} evaluates to \TRUE{}
@@ -11400,7 +11407,8 @@ \subsubsection{Sets}
1140011407
and it is evaluated at run time.
1140111408
Only run-time set literals can be mutated after they are created.
1140211409
% This error can occur because being constant is a dynamic property, here.
11403-
Attempting to mutate a constant set literal will result in a dynamic error.
11410+
Attempting to mutate a constant set literal
11411+
will result in a \DynamicError{dynamic error}.
1140411412

1140511413
\commentary{%
1140611414
% The following is true either directly or indirectly: There is a \CONST{}
@@ -11606,7 +11614,8 @@ \subsubsection{Maps}
1160611614
and it is evaluated at run time.
1160711615
Only run-time map literals can be mutated after they are created.
1160811616
% This error can occur because being constant is a dynamic property, here.
11609-
Attempting to mutate a constant map literal will result in a dynamic error.
11617+
Attempting to mutate a constant map literal
11618+
will result in a \DynamicError{dynamic error}.
1161011619

1161111620
\commentary{%
1161211621
% The following is true either directly or indirectly: There is a \CONST{}
@@ -11747,7 +11756,8 @@ \subsection{Throw}
1174711756
}
1174811757

1174911758
\LMHash{}%
11750-
If $v$ is the null object (\ref{null}), then a dynamic error occurs.
11759+
If $v$ is the null object (\ref{null})
11760+
then a \DynamicError{dynamic error} occurs.
1175111761
Otherwise let $t$ be a stack trace corresponding to the current execution state,
1175211762
and the \THROW{} statement throws with $v$ as exception object
1175311763
and $t$ as stack trace (\ref{expressionEvaluation}).
@@ -12261,7 +12271,7 @@ \subsubsection{New}
1226112271
% This error can occur because being-loaded is a dynamic property.
1226212272
If $T$ is a deferred type with prefix $p$,
1226312273
then if $p$ has not been successfully loaded,
12264-
a dynamic error occurs.
12274+
a \DynamicError{dynamic error} occurs.
1226512275
\EndCase
1226612276

1226712277
\LMHash{}%
@@ -13189,7 +13199,7 @@ \subsubsection{Binding Actuals to Formals}
1318913199
If $r = 0$ and $s > 0$ then
1319013200
if $f$ does not have default type arguments
1319113201
(\ref{instantiationToBound})
13192-
then a dynamic error occurs.
13202+
then a \DynamicError{dynamic error} occurs.
1319313203
Otherwise replace the actual type argument list:
1319413204
Let $r$ be $s$ and let $t_i$ for $i \in 1 .. s$ be the result of
1319513205
instantiation to bound
@@ -16154,7 +16164,8 @@ \subsection{Assignment}
1615416164
in which case $v$ has no initializer and is not definitely assigned,
1615516165
or a compile-time error would have occurred%
1615616166
}).
16157-
If $v$ has previously been bound to an object then a dynamic error occurs.
16167+
If $v$ has previously been bound to an object
16168+
then a \DynamicError{dynamic error} occurs.
1615816169
Otherwise, $v$ is bound to $o$, and then $a$ evaluates to $o$
1615916170
(\ref{expressionEvaluation}).
1616016171
\item
@@ -16706,7 +16717,8 @@ \subsection{Conditional}
1670616717
proceeds as follows:
1670716718
Evaluate $e_1$ to an object $o_1$.
1670816719
% This error can occur due to an implicit cast from \DYNAMIC.
16709-
It is a dynamic error if the run-time type of $o_1$ is not \code{bool}.
16720+
It is a \DynamicError{dynamic error}
16721+
if the run-time type of $o_1$ is not \code{bool}.
1671016722
If $o_1$ is the \TRUE{} object, then the value of $c$ is
1671116723
the result of evaluating the expression $e_2$.
1671216724
Otherwise, the value of $c$ is the result of evaluating the expression $e_3$.
@@ -16774,23 +16786,27 @@ \subsection{Logical Boolean Expressions}
1677416786
\code{$e_1$\,\,||\,\,$e_2$}
1677516787
causes the evaluation of $e_1$ to an object $o_1$.
1677616788
% This error can occur due to an implicit downcast from \DYNAMIC.
16777-
It is a dynamic error if the run-time type of $o_1$ is not \code{bool}.
16789+
It is a \DynamicError{dynamic error}
16790+
if the run-time type of $o_1$ is not \code{bool}.
1677816791
If $o_1$ is \TRUE, the result of evaluating $b$ is \TRUE,
1677916792
otherwise $e_2$ is evaluated to an object $o_2$.
1678016793
% This error can occur due to an implicit downcast from \DYNAMIC.
16781-
It is a dynamic error if the run-time type of $o_2$ is not \code{bool}.
16794+
It is a \DynamicError{dynamic error}
16795+
if the run-time type of $o_2$ is not \code{bool}.
1678216796
Otherwise the result of evaluating $b$ is $o_2$.
1678316797

1678416798
\LMHash{}%
1678516799
Evaluation of a logical boolean expression $b$ of the form
1678616800
\code{$e_1$\,\,\&\&\,\,$e_2$}
1678716801
causes the evaluation of $e_1$ to an object $o_1$.
1678816802
% This error can occur due to an implicit downcast from \DYNAMIC.
16789-
It is a dynamic error if the run-time type of $o_1$ is not \code{bool}.
16803+
It is a \DynamicError{dynamic error}
16804+
if the run-time type of $o_1$ is not \code{bool}.
1679016805
If $o_1$ is \FALSE, the result of evaluating $b$ is \FALSE,
1679116806
otherwise $e_2$ is evaluated to an object $o_2$.
1679216807
% This error can occur due to an implicit downcast from \DYNAMIC.
16793-
It is a dynamic error if the run-time type of $o_2$ is not \code{bool}.
16808+
It is a \DynamicError{dynamic error}
16809+
if the run-time type of $o_2$ is not \code{bool}.
1679416810
Otherwise the result of evaluating $b$ is $o_2$.
1679516811

1679616812

@@ -17325,7 +17341,7 @@ \subsection{Postfix Expressions}
1732517341

1732617342
\LMHash{}%
1732717343
$e$ is evaluated as follows: $e_1$ is evaluated to an object $o$.
17328-
If $o$ is the null object then a dynamic error occurs,
17344+
If $o$ is the null object then a \DynamicError{dynamic error} occurs,
1732917345
otherwise $e$ evaluates to $o$.
1733017346
\EndCase
1733117347

@@ -18655,7 +18671,7 @@ \subsection{Local Variable Declaration}
1865518671
then $v$ is bound to $o$.
1865618672
If an object $o$ is assigned to $v$
1865718673
in a situation where $v$ is bound to an object $o'$
18658-
then a dynamic error occurs
18674+
then a \DynamicError{dynamic error} occurs
1865918675
(\commentary{it does not matter whether $o$ is the same object as $o'$}).
1866018676

1866118677
\commentary{%
@@ -18816,7 +18832,8 @@ \subsection{If}
1881618832
proceeds as follows:
1881718833
Evaluate the expression $e$ to an object $o$.
1881818834
% This error can occur due to an implicit downcast from \DYNAMIC.
18819-
It is a dynamic error if the run-time type of $o$ is not \code{bool}.
18835+
It is a \DynamicError{dynamic error}
18836+
if the run-time type of $o$ is not \code{bool}.
1882018837
If $o$ is \TRUE, then execute the block statement $S_1$,
1882118838
otherwise execute the block statement $S_2$.
1882218839

@@ -18899,7 +18916,8 @@ \subsubsection{For Loop}
1889918916
\item
1890018917
The expression $[v'/v]c$ is evaluated to an object $o$.
1890118918
% This error can occur due to an implicit downcast from \DYNAMIC.
18902-
It is a dynamic error if the run-time type of $o$ is not \code{bool}.
18919+
It is a \DynamicError{dynamic error}
18920+
if the run-time type of $o$ is not \code{bool}.
1890318921
If $o$ is \FALSE, the for loop completes normally.
1890418922
Otherwise, execution continues at step \ref{beginIteration}.
1890518923
\item
@@ -19109,7 +19127,8 @@ \subsection{While}
1910919127
\LMHash{}%
1911019128
The expression $e$ is evaluated to an object $o$.
1911119129
% This error can occur due to an implicit downcast from \DYNAMIC.
19112-
It is a dynamic error if the run-time type of $o$ is not \code{bool}.
19130+
It is a \DynamicError{dynamic error}
19131+
if the run-time type of $o$ is not \code{bool}.
1911319132

1911419133
\LMHash{}%
1911519134
If $o$ is \FALSE, then execution of the while statement completes normally
@@ -19160,7 +19179,8 @@ \subsection{Do}
1916019179
\LMHash{}%
1916119180
Then, the expression $e$ is evaluated to an object $o$.
1916219181
% This error can occur due to an implicit downcast from \DYNAMIC.
19163-
It is a dynamic error if the run-time type of $o$ is not \code{bool}.
19182+
It is a \DynamicError{dynamic error}
19183+
if the run-time type of $o$ is not \code{bool}.
1916419184
If $o$ is \FALSE, execution of the do statement completes normally
1916519185
(\ref{statementCompletion}).
1916619186
If $o$ is \TRUE, then the do statement is re-executed.
@@ -19851,7 +19871,8 @@ \subsection{Return}
1985119871

1985219872
\LMHash{}%
1985319873
The expression $e$ is evaluated to an object $o$.
19854-
A dynamic error occurs unless the dynamic type of $o$ is a subtype of
19874+
A \DynamicError{dynamic error} occurs
19875+
unless the dynamic type of $o$ is a subtype of
1985519876
the actual return type of $f$
1985619877
(\ref{actualTypes}).
1985719878
Then the return statement $s$ completes returning $o$
@@ -19878,7 +19899,8 @@ \subsection{Return}
1987819899
let \code{v} be a fresh variable bound to $o$ and
1987919900
evaluate \code{\AWAIT{} v} to an object $r$;
1988019901
otherwise let $r$ be $o$.
19881-
A dynamic error occurs unless the dynamic type of $r$
19902+
A \DynamicError{dynamic error} occurs
19903+
unless the dynamic type of $r$
1988219904
is a subtype of the actual value of $T_v$
1988319905
(\ref{actualTypes}).
1988419906
Then the return statement $s$ completes returning $r$
@@ -20763,28 +20785,28 @@ \subsubsection{Semantics of Imports}
2076320785
\NamespaceName{\metavar{import},i},
2076420786
a corresponding function named \id{} with the same function header as $f$.
2076520787
% This error can occur because being-loaded is a dynamic property.
20766-
Calling the function results in a dynamic error,
20788+
Calling the function results in a \DynamicError{dynamic error},
2076720789
and so does closurizing it
2076820790
(\ref{functionClosurization}).
2076920791
\item
2077020792
For every top level getter $g$ named \id{} in
2077120793
\NamespaceName{\metavar{import},i},
2077220794
a corresponding getter named \id{} with the same function header as $g$.
2077320795
% This error can occur because being-loaded is a dynamic property.
20774-
Calling the getter results in a dynamic error.
20796+
Calling the getter results in a \DynamicError{dynamic error}.
2077520797
\item
2077620798
For every top level setter $s$ named \code{\id=} in
2077720799
\NamespaceName{\metavar{import},i},
2077820800
a corresponding setter named \code{\id=} with
2077920801
the same function header as $s$.
2078020802
% This error can occur because being-loaded is a dynamic property.
20781-
Calling the setter results in a dynamic error.
20803+
Calling the setter results in a \DynamicError{dynamic error}.
2078220804
\item
2078320805
For every class, mixin and type alias declaration named \id{} in
2078420806
\NamespaceName{\metavar{import},i},
2078520807
a corresponding getter named \id{} with return type \code{Type}.
2078620808
% This error can occur because being-loaded is a dynamic property.
20787-
Calling the getter results in a dynamic error.
20809+
Calling the getter results in a \DynamicError{dynamic error}.
2078820810
\end{itemize}
2078920811

2079020812
\rationale{%
@@ -21318,7 +21340,7 @@ \subsection{Scripts}
2131821340
that spawned $i$%
2131921341
}),
2132021342
or the null object if no such object was supplied.
21321-
A dynamic error occurs if
21343+
A \DynamicError{dynamic error} occurs if
2132221344
the run-time type of this object is not a subtype of
2132321345
the declared type of the corresponding parameter of \code{main}.
2132421346
\end{itemize}
@@ -21341,7 +21363,7 @@ \subsection{Scripts}
2134121363
(\commentary{%
2134221364
the above rules ensure that the corresponding parameters are optional%
2134321365
}).
21344-
But the implementation must ensure that a dynamic error occurs
21366+
But the implementation must ensure that a \DynamicError{dynamic error} occurs
2134521367
if an actual argument does not have a run-time type which is
2134621368
a subtype of the declared type of the parameter.
2134721369

0 commit comments

Comments
 (0)