Skip to content

Commit ced3050

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

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
@@ -16168,7 +16176,8 @@ \subsection{Assignment}
1616816176
in which case $v$ has no initializer and is not definitely assigned,
1616916177
or a compile-time error would have occurred%
1617016178
}).
16171-
If $v$ has previously been bound to an object then a dynamic error occurs.
16179+
If $v$ has previously been bound to an object
16180+
then a \DynamicError{dynamic error} occurs.
1617216181
Otherwise, $v$ is bound to $o$, and then $a$ evaluates to $o$
1617316182
(\ref{expressionEvaluation}).
1617416183
\item
@@ -16720,7 +16729,8 @@ \subsection{Conditional}
1672016729
proceeds as follows:
1672116730
Evaluate $e_1$ to an object $o_1$.
1672216731
% This error can occur due to an implicit cast from \DYNAMIC.
16723-
It is a dynamic error if the run-time type of $o_1$ is not \code{bool}.
16732+
It is a \DynamicError{dynamic error}
16733+
if the run-time type of $o_1$ is not \code{bool}.
1672416734
If $o_1$ is the \TRUE{} object, then the value of $c$ is
1672516735
the result of evaluating the expression $e_2$.
1672616736
Otherwise, the value of $c$ is the result of evaluating the expression $e_3$.
@@ -16788,23 +16798,27 @@ \subsection{Logical Boolean Expressions}
1678816798
\code{$e_1$\,\,||\,\,$e_2$}
1678916799
causes the evaluation of $e_1$ to an object $o_1$.
1679016800
% This error can occur due to an implicit downcast from \DYNAMIC.
16791-
It is a dynamic error if the run-time type of $o_1$ is not \code{bool}.
16801+
It is a \DynamicError{dynamic error}
16802+
if the run-time type of $o_1$ is not \code{bool}.
1679216803
If $o_1$ is \TRUE, the result of evaluating $b$ is \TRUE,
1679316804
otherwise $e_2$ is evaluated to an object $o_2$.
1679416805
% This error can occur due to an implicit downcast from \DYNAMIC.
16795-
It is a dynamic error if the run-time type of $o_2$ is not \code{bool}.
16806+
It is a \DynamicError{dynamic error}
16807+
if the run-time type of $o_2$ is not \code{bool}.
1679616808
Otherwise the result of evaluating $b$ is $o_2$.
1679716809

1679816810
\LMHash{}%
1679916811
Evaluation of a logical boolean expression $b$ of the form
1680016812
\code{$e_1$\,\,\&\&\,\,$e_2$}
1680116813
causes the evaluation of $e_1$ to an object $o_1$.
1680216814
% This error can occur due to an implicit downcast from \DYNAMIC.
16803-
It is a dynamic error if the run-time type of $o_1$ is not \code{bool}.
16815+
It is a \DynamicError{dynamic error}
16816+
if the run-time type of $o_1$ is not \code{bool}.
1680416817
If $o_1$ is \FALSE, the result of evaluating $b$ is \FALSE,
1680516818
otherwise $e_2$ is evaluated to an object $o_2$.
1680616819
% This error can occur due to an implicit downcast from \DYNAMIC.
16807-
It is a dynamic error if the run-time type of $o_2$ is not \code{bool}.
16820+
It is a \DynamicError{dynamic error}
16821+
if the run-time type of $o_2$ is not \code{bool}.
1680816822
Otherwise the result of evaluating $b$ is $o_2$.
1680916823

1681016824

@@ -17339,7 +17353,7 @@ \subsection{Postfix Expressions}
1733917353

1734017354
\LMHash{}%
1734117355
$e$ is evaluated as follows: $e_1$ is evaluated to an object $o$.
17342-
If $o$ is the null object then a dynamic error occurs,
17356+
If $o$ is the null object then a \DynamicError{dynamic error} occurs,
1734317357
otherwise $e$ evaluates to $o$.
1734417358
\EndCase
1734517359

@@ -18669,7 +18683,7 @@ \subsection{Local Variable Declaration}
1866918683
then $v$ is bound to $o$.
1867018684
If an object $o$ is assigned to $v$
1867118685
in a situation where $v$ is bound to an object $o'$
18672-
then a dynamic error occurs
18686+
then a \DynamicError{dynamic error} occurs
1867318687
(\commentary{it does not matter whether $o$ is the same object as $o'$}).
1867418688

1867518689
\commentary{%
@@ -18830,7 +18844,8 @@ \subsection{If}
1883018844
proceeds as follows:
1883118845
Evaluate the expression $e$ to an object $o$.
1883218846
% This error can occur due to an implicit downcast from \DYNAMIC.
18833-
It is a dynamic error if the run-time type of $o$ is not \code{bool}.
18847+
It is a \DynamicError{dynamic error}
18848+
if the run-time type of $o$ is not \code{bool}.
1883418849
If $o$ is \TRUE, then execute the block statement $S_1$,
1883518850
otherwise execute the block statement $S_2$.
1883618851

@@ -18913,7 +18928,8 @@ \subsubsection{For Loop}
1891318928
\item
1891418929
The expression $[v'/v]c$ is evaluated to an object $o$.
1891518930
% This error can occur due to an implicit downcast from \DYNAMIC.
18916-
It is a dynamic error if the run-time type of $o$ is not \code{bool}.
18931+
It is a \DynamicError{dynamic error}
18932+
if the run-time type of $o$ is not \code{bool}.
1891718933
If $o$ is \FALSE, the for loop completes normally.
1891818934
Otherwise, execution continues at step \ref{beginIteration}.
1891918935
\item
@@ -19123,7 +19139,8 @@ \subsection{While}
1912319139
\LMHash{}%
1912419140
The expression $e$ is evaluated to an object $o$.
1912519141
% This error can occur due to an implicit downcast from \DYNAMIC.
19126-
It is a dynamic error if the run-time type of $o$ is not \code{bool}.
19142+
It is a \DynamicError{dynamic error}
19143+
if the run-time type of $o$ is not \code{bool}.
1912719144

1912819145
\LMHash{}%
1912919146
If $o$ is \FALSE, then execution of the while statement completes normally
@@ -19174,7 +19191,8 @@ \subsection{Do}
1917419191
\LMHash{}%
1917519192
Then, the expression $e$ is evaluated to an object $o$.
1917619193
% This error can occur due to an implicit downcast from \DYNAMIC.
19177-
It is a dynamic error if the run-time type of $o$ is not \code{bool}.
19194+
It is a \DynamicError{dynamic error}
19195+
if the run-time type of $o$ is not \code{bool}.
1917819196
If $o$ is \FALSE, execution of the do statement completes normally
1917919197
(\ref{statementCompletion}).
1918019198
If $o$ is \TRUE, then the do statement is re-executed.
@@ -19865,7 +19883,8 @@ \subsection{Return}
1986519883

1986619884
\LMHash{}%
1986719885
The expression $e$ is evaluated to an object $o$.
19868-
A dynamic error occurs unless the dynamic type of $o$ is a subtype of
19886+
A \DynamicError{dynamic error} occurs
19887+
unless the dynamic type of $o$ is a subtype of
1986919888
the actual return type of $f$
1987019889
(\ref{actualTypes}).
1987119890
Then the return statement $s$ completes returning $o$
@@ -19892,7 +19911,8 @@ \subsection{Return}
1989219911
let \code{v} be a fresh variable bound to $o$ and
1989319912
evaluate \code{\AWAIT{} v} to an object $r$;
1989419913
otherwise let $r$ be $o$.
19895-
A dynamic error occurs unless the dynamic type of $r$
19914+
A \DynamicError{dynamic error} occurs
19915+
unless the dynamic type of $r$
1989619916
is a subtype of the actual value of $T_v$
1989719917
(\ref{actualTypes}).
1989819918
Then the return statement $s$ completes returning $r$
@@ -20777,28 +20797,28 @@ \subsubsection{Semantics of Imports}
2077720797
\NamespaceName{\metavar{import},i},
2077820798
a corresponding function named \id{} with the same function header as $f$.
2077920799
% This error can occur because being-loaded is a dynamic property.
20780-
Calling the function results in a dynamic error,
20800+
Calling the function results in a \DynamicError{dynamic error},
2078120801
and so does closurizing it
2078220802
(\ref{functionClosurization}).
2078320803
\item
2078420804
For every top level getter $g$ named \id{} in
2078520805
\NamespaceName{\metavar{import},i},
2078620806
a corresponding getter named \id{} with the same function header as $g$.
2078720807
% This error can occur because being-loaded is a dynamic property.
20788-
Calling the getter results in a dynamic error.
20808+
Calling the getter results in a \DynamicError{dynamic error}.
2078920809
\item
2079020810
For every top level setter $s$ named \code{\id=} in
2079120811
\NamespaceName{\metavar{import},i},
2079220812
a corresponding setter named \code{\id=} with
2079320813
the same function header as $s$.
2079420814
% This error can occur because being-loaded is a dynamic property.
20795-
Calling the setter results in a dynamic error.
20815+
Calling the setter results in a \DynamicError{dynamic error}.
2079620816
\item
2079720817
For every class, mixin and type alias declaration named \id{} in
2079820818
\NamespaceName{\metavar{import},i},
2079920819
a corresponding getter named \id{} with return type \code{Type}.
2080020820
% This error can occur because being-loaded is a dynamic property.
20801-
Calling the getter results in a dynamic error.
20821+
Calling the getter results in a \DynamicError{dynamic error}.
2080220822
\end{itemize}
2080320823

2080420824
\rationale{%
@@ -21332,7 +21352,7 @@ \subsection{Scripts}
2133221352
that spawned $i$%
2133321353
}),
2133421354
or the null object if no such object was supplied.
21335-
A dynamic error occurs if
21355+
A \DynamicError{dynamic error} occurs if
2133621356
the run-time type of this object is not a subtype of
2133721357
the declared type of the corresponding parameter of \code{main}.
2133821358
\end{itemize}
@@ -21355,7 +21375,7 @@ \subsection{Scripts}
2135521375
(\commentary{%
2135621376
the above rules ensure that the corresponding parameters are optional%
2135721377
}).
21358-
But the implementation must ensure that a dynamic error occurs
21378+
But the implementation must ensure that a \DynamicError{dynamic error} occurs
2135921379
if an actual argument does not have a run-time type which is
2136021380
a subtype of the declared type of the parameter.
2136121381

0 commit comments

Comments
 (0)