Skip to content

Commit 3e88818

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

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}\\
@@ -65,9 +66,11 @@
6566
% error anyway; change extension names to `typeIdentifier`, avoiding
6667
% built-in identifiers).
6768
%
68-
% Feb 2023
69+
% Jan, Feb 2023
6970
% - Change the specification of constant expressions of the form `e1 == e2`
7071
% to use primitive equality.
72+
% - Introduce `\DynamicError{}`, thus marking every introduction (definition)
73+
% of a dynamic error by a lightning symbol in the right margin.
7174
%
7275
% Dec 2022
7376
% - Change the definition of the type function 'flatten' to resolve soundness
@@ -1580,7 +1583,7 @@ \subsection{Implicitly Induced Getters and Setters}
15801583
will bind \id{} to the object that the argument $x$ is bound to.
15811584
An execution of the setter
15821585
in a situation where the variable \id{} has been bound to an object
1583-
will incur a dynamic error.
1586+
will incur a \DynamicError{dynamic error}.
15841587
\EndCase
15851588

15861589
\LMHash{}%
@@ -4173,7 +4176,7 @@ \subsubsection{Generative Constructors}
41734176
% This can occur due to a failing implicit cast.
41744177
unless the assigned object has a dynamic type
41754178
which is not a subtype of the declared type of the instance variable \id,
4176-
in which case a dynamic error occurs.
4179+
in which case a \DynamicError{dynamic error} occurs.
41774180

41784181
\commentary{%
41794182
The above rule allows initializing formals to be used as optional parameters:%
@@ -10464,7 +10467,7 @@ \subsubsection{Collection Literal Element Evaluation}
1046410467
or the given \code{value} does not have the type \code{Value},
1046510468
but it cannot occur after the pair has been appended to $s$.
1046610469
\item
10467-
Otherwise, a dynamic error occurs.
10470+
Otherwise, a \DynamicError{dynamic error} occurs.
1046810471

1046910472
\commentary{%
1047010473
This occurs when the target is an iterable respectively a map,
@@ -10519,7 +10522,8 @@ \subsubsection{Collection Literal Element Evaluation}
1051910522
and if $\ell_2$ is not present then
1052010523
$\EvaluateElement{\ell} := \LiteralSequence{}$.
1052110524
% $o_b$ can have type \DYNAMIC.
10522-
If $o_b$ is neither \TRUE{} nor \FALSE{} then a dynamic error occurs.
10525+
If $o_b$ is neither \TRUE{} nor \FALSE{}
10526+
then a \DynamicError{dynamic error} occurs.
1052310527
\EndCase
1052410528

1052510529
\LMHash{}%
@@ -10750,7 +10754,7 @@ \subsubsection{Lists}
1075010754
An empty list has an empty set of indices.
1075110755
A non-empty list has the index set $\{0, \ldots, n - 1\}$
1075210756
where $n$ is the size of the list.
10753-
It is a dynamic error to attempt to access a list
10757+
It is a \DynamicError{dynamic error} to attempt to access a list
1075410758
using an index that is not a member of its set of indices.
1075510759

1075610760
\rationale{%
@@ -10774,7 +10778,8 @@ \subsubsection{Lists}
1077410778
Only run-time list literals can be mutated
1077510779
after they are created.
1077610780
% This error can occur because being constant is a dynamic property.
10777-
Attempting to mutate a constant list literal will result in a dynamic error.
10781+
Attempting to mutate a constant list literal
10782+
will result in a \DynamicError{dynamic error}.
1077810783

1077910784
\commentary{%
1078010785
% The following is true either directly or indirectly: There is a \CONST{}
@@ -11543,7 +11548,7 @@ \subsubsection{Sets}
1154311548
\LMHash{}%
1154411549
A set may contain zero or more objects.
1154511550
Sets have a method which can be used to insert objects;
11546-
this will incur a dynamic error if the set is not modifiable.
11551+
this will incur a \DynamicError{dynamic error} if the set is not modifiable.
1154711552
Otherwise, when inserting an object $o_{\metavar{new}}$ into a set $s$,
1154811553
if an object $o_{\metavar{old}}$ exists in $s$ such that
1154911554
\code{$o_{\metavar{old}}$ == $o_{\metavar{new}}$} evaluates to \TRUE{}
@@ -11583,7 +11588,8 @@ \subsubsection{Sets}
1158311588
and it is evaluated at run time.
1158411589
Only run-time set literals can be mutated after they are created.
1158511590
% This error can occur because being constant is a dynamic property, here.
11586-
Attempting to mutate a constant set literal will result in a dynamic error.
11591+
Attempting to mutate a constant set literal
11592+
will result in a \DynamicError{dynamic error}.
1158711593

1158811594
\commentary{%
1158911595
% The following is true either directly or indirectly: There is a \CONST{}
@@ -11789,7 +11795,8 @@ \subsubsection{Maps}
1178911795
and it is evaluated at run time.
1179011796
Only run-time map literals can be mutated after they are created.
1179111797
% This error can occur because being constant is a dynamic property, here.
11792-
Attempting to mutate a constant map literal will result in a dynamic error.
11798+
Attempting to mutate a constant map literal
11799+
will result in a \DynamicError{dynamic error}.
1179311800

1179411801
\commentary{%
1179511802
% The following is true either directly or indirectly: There is a \CONST{}
@@ -11930,7 +11937,8 @@ \subsection{Throw}
1193011937
}
1193111938

1193211939
\LMHash{}%
11933-
If $v$ is the null object (\ref{null}), then a dynamic error occurs.
11940+
If $v$ is the null object (\ref{null})
11941+
then a \DynamicError{dynamic error} occurs.
1193411942
Otherwise let $t$ be a stack trace corresponding to the current execution state,
1193511943
and the \THROW{} statement throws with $v$ as exception object
1193611944
and $t$ as stack trace (\ref{expressionEvaluation}).
@@ -12450,7 +12458,7 @@ \subsubsection{New}
1245012458
% This error can occur because being-loaded is a dynamic property.
1245112459
If $T$ is a deferred type with prefix $p$,
1245212460
then if $p$ has not been successfully loaded,
12453-
a dynamic error occurs.
12461+
a \DynamicError{dynamic error} occurs.
1245412462
\EndCase
1245512463

1245612464
\LMHash{}%
@@ -13379,7 +13387,7 @@ \subsubsection{Binding Actuals to Formals}
1337913387
If $r = 0$ and $s > 0$ then
1338013388
if $f$ does not have default type arguments
1338113389
(\ref{instantiationToBound})
13382-
then a dynamic error occurs.
13390+
then a \DynamicError{dynamic error} occurs.
1338313391
Otherwise replace the actual type argument list:
1338413392
Let $r$ be $s$ and let $t_i$ for $i \in 1 .. s$ be the result of
1338513393
instantiation to bound
@@ -16402,7 +16410,8 @@ \subsection{Assignment}
1640216410
in which case $v$ has no initializer and is not definitely assigned,
1640316411
or a compile-time error would have occurred%
1640416412
}).
16405-
If $v$ has previously been bound to an object then a dynamic error occurs.
16413+
If $v$ has previously been bound to an object
16414+
then a \DynamicError{dynamic error} occurs.
1640616415
Otherwise, $v$ is bound to $o$, and then $a$ evaluates to $o$
1640716416
(\ref{expressionEvaluation}).
1640816417
\item
@@ -16954,7 +16963,8 @@ \subsection{Conditional}
1695416963
proceeds as follows:
1695516964
Evaluate $e_1$ to an object $o_1$.
1695616965
% This error can occur due to an implicit cast from \DYNAMIC.
16957-
It is a dynamic error if the run-time type of $o_1$ is not \code{bool}.
16966+
It is a \DynamicError{dynamic error}
16967+
if the run-time type of $o_1$ is not \code{bool}.
1695816968
If $o_1$ is the \TRUE{} object, then the value of $c$ is
1695916969
the result of evaluating the expression $e_2$.
1696016970
Otherwise, the value of $c$ is the result of evaluating the expression $e_3$.
@@ -17022,23 +17032,27 @@ \subsection{Logical Boolean Expressions}
1702217032
\code{$e_1$\,\,||\,\,$e_2$}
1702317033
causes the evaluation of $e_1$ to an object $o_1$.
1702417034
% This error can occur due to an implicit downcast from \DYNAMIC.
17025-
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}.
1702617037
If $o_1$ is \TRUE, the result of evaluating $b$ is \TRUE,
1702717038
otherwise $e_2$ is evaluated to an object $o_2$.
1702817039
% This error can occur due to an implicit downcast from \DYNAMIC.
17029-
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}.
1703017042
Otherwise the result of evaluating $b$ is $o_2$.
1703117043

1703217044
\LMHash{}%
1703317045
Evaluation of a logical boolean expression $b$ of the form
1703417046
\code{$e_1$\,\,\&\&\,\,$e_2$}
1703517047
causes the evaluation of $e_1$ to an object $o_1$.
1703617048
% This error can occur due to an implicit downcast from \DYNAMIC.
17037-
It is a dynamic error if the run-time type of $o_1$ is not \code{bool}.
17049+
It is a \DynamicError{dynamic error}
17050+
if the run-time type of $o_1$ is not \code{bool}.
1703817051
If $o_1$ is \FALSE, the result of evaluating $b$ is \FALSE,
1703917052
otherwise $e_2$ is evaluated to an object $o_2$.
1704017053
% This error can occur due to an implicit downcast from \DYNAMIC.
17041-
It is a dynamic error if the run-time type of $o_2$ is not \code{bool}.
17054+
It is a \DynamicError{dynamic error}
17055+
if the run-time type of $o_2$ is not \code{bool}.
1704217056
Otherwise the result of evaluating $b$ is $o_2$.
1704317057

1704417058

@@ -17623,7 +17637,7 @@ \subsection{Postfix Expressions}
1762317637

1762417638
\LMHash{}%
1762517639
$e$ is evaluated as follows: $e_1$ is evaluated to an object $o$.
17626-
If $o$ is the null object then a dynamic error occurs,
17640+
If $o$ is the null object then a \DynamicError{dynamic error} occurs,
1762717641
otherwise $e$ evaluates to $o$.
1762817642
\EndCase
1762917643

@@ -18951,7 +18965,7 @@ \subsection{Local Variable Declaration}
1895118965
then $v$ is bound to $o$.
1895218966
If an object $o$ is assigned to $v$
1895318967
in a situation where $v$ is bound to an object $o'$
18954-
then a dynamic error occurs
18968+
then a \DynamicError{dynamic error} occurs
1895518969
(\commentary{it does not matter whether $o$ is the same object as $o'$}).
1895618970

1895718971
\commentary{%
@@ -19112,7 +19126,8 @@ \subsection{If}
1911219126
proceeds as follows:
1911319127
Evaluate the expression $e$ to an object $o$.
1911419128
% This error can occur due to an implicit downcast from \DYNAMIC.
19115-
It is a dynamic error if the run-time type of $o$ is not \code{bool}.
19129+
It is a \DynamicError{dynamic error}
19130+
if the run-time type of $o$ is not \code{bool}.
1911619131
If $o$ is \TRUE, then execute the block statement $S_1$,
1911719132
otherwise execute the block statement $S_2$.
1911819133

@@ -19195,7 +19210,8 @@ \subsubsection{For Loop}
1919519210
\item
1919619211
The expression $[v'/v]c$ is evaluated to an object $o$.
1919719212
% This error can occur due to an implicit downcast from \DYNAMIC.
19198-
It is a dynamic error if the run-time type of $o$ is not \code{bool}.
19213+
It is a \DynamicError{dynamic error}
19214+
if the run-time type of $o$ is not \code{bool}.
1919919215
If $o$ is \FALSE, the for loop completes normally.
1920019216
Otherwise, execution continues at step \ref{beginIteration}.
1920119217
\item
@@ -19408,7 +19424,8 @@ \subsection{While}
1940819424
\LMHash{}%
1940919425
The expression $e$ is evaluated to an object $o$.
1941019426
% This error can occur due to an implicit downcast from \DYNAMIC.
19411-
It is a dynamic error if the run-time type of $o$ is not \code{bool}.
19427+
It is a \DynamicError{dynamic error}
19428+
if the run-time type of $o$ is not \code{bool}.
1941219429

1941319430
\LMHash{}%
1941419431
If $o$ is \FALSE, then execution of the while statement completes normally
@@ -19459,7 +19476,8 @@ \subsection{Do}
1945919476
\LMHash{}%
1946019477
Then, the expression $e$ is evaluated to an object $o$.
1946119478
% This error can occur due to an implicit downcast from \DYNAMIC.
19462-
It is a dynamic error if the run-time type of $o$ is not \code{bool}.
19479+
It is a \DynamicError{dynamic error}
19480+
if the run-time type of $o$ is not \code{bool}.
1946319481
If $o$ is \FALSE, execution of the do statement completes normally
1946419482
(\ref{statementCompletion}).
1946519483
If $o$ is \TRUE, then the do statement is re-executed.
@@ -20150,7 +20168,8 @@ \subsection{Return}
2015020168

2015120169
\LMHash{}%
2015220170
The expression $e$ is evaluated to an object $o$.
20153-
A dynamic error occurs unless the dynamic type of $o$ is a subtype of
20171+
A \DynamicError{dynamic error} occurs
20172+
unless the dynamic type of $o$ is a subtype of
2015420173
the actual return type of $f$
2015520174
(\ref{actualTypes}).
2015620175
Then the return statement $s$ completes returning $o$
@@ -20177,7 +20196,8 @@ \subsection{Return}
2017720196
let \code{v} be a fresh variable bound to $o$ and
2017820197
evaluate \code{\AWAIT{} v} to an object $r$;
2017920198
otherwise let $r$ be $o$.
20180-
A dynamic error occurs unless the dynamic type of $r$
20199+
A \DynamicError{dynamic error} occurs
20200+
unless the dynamic type of $r$
2018120201
is a subtype of the actual value of $T_v$
2018220202
(\ref{actualTypes}).
2018320203
Then the return statement $s$ completes returning $r$
@@ -21062,28 +21082,28 @@ \subsubsection{Semantics of Imports}
2106221082
\NamespaceName{\metavar{import},i},
2106321083
a corresponding function named \id{} with the same function header as $f$.
2106421084
% This error can occur because being-loaded is a dynamic property.
21065-
Calling the function results in a dynamic error,
21085+
Calling the function results in a \DynamicError{dynamic error},
2106621086
and so does closurizing it
2106721087
(\ref{functionClosurization}).
2106821088
\item
2106921089
For every top level getter $g$ named \id{} in
2107021090
\NamespaceName{\metavar{import},i},
2107121091
a corresponding getter named \id{} with the same function header as $g$.
2107221092
% This error can occur because being-loaded is a dynamic property.
21073-
Calling the getter results in a dynamic error.
21093+
Calling the getter results in a \DynamicError{dynamic error}.
2107421094
\item
2107521095
For every top level setter $s$ named \code{\id=} in
2107621096
\NamespaceName{\metavar{import},i},
2107721097
a corresponding setter named \code{\id=} with
2107821098
the same function header as $s$.
2107921099
% This error can occur because being-loaded is a dynamic property.
21080-
Calling the setter results in a dynamic error.
21100+
Calling the setter results in a \DynamicError{dynamic error}.
2108121101
\item
2108221102
For every class, mixin, enum, and type alias declaration named \id{} in
2108321103
\NamespaceName{\metavar{import},i},
2108421104
a corresponding getter named \id{} with return type \code{Type}.
2108521105
% This error can occur because being-loaded is a dynamic property.
21086-
Calling the getter results in a dynamic error.
21106+
Calling the getter results in a \DynamicError{dynamic error}.
2108721107
\end{itemize}
2108821108

2108921109
\rationale{%
@@ -21617,7 +21637,7 @@ \subsection{Scripts}
2161721637
that spawned $i$%
2161821638
}),
2161921639
or the null object if no such object was supplied.
21620-
A dynamic error occurs if
21640+
A \DynamicError{dynamic error} occurs if
2162121641
the run-time type of this object is not a subtype of
2162221642
the declared type of the corresponding parameter of \code{main}.
2162321643
\end{itemize}
@@ -21640,7 +21660,7 @@ \subsection{Scripts}
2164021660
(\commentary{%
2164121661
the above rules ensure that the corresponding parameters are optional%
2164221662
}).
21643-
But the implementation must ensure that a dynamic error occurs
21663+
But the implementation must ensure that a \DynamicError{dynamic error} occurs
2164421664
if an actual argument does not have a run-time type which is
2164521665
a subtype of the declared type of the parameter.
2164621666

0 commit comments

Comments
 (0)