Skip to content

Commit fd71308

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

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
@@ -175,7 +175,7 @@
175175

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

180180
% Used for the defining occurrence of a local symbol.
181181
\newcommand{\DefineSymbol}[1]{%
@@ -196,11 +196,15 @@
196196

197197
% Same appearance, but not adding an entry to the index.
198198
\newcommand{\NoIndex}[1]{%
199-
\leavevmode\marginpar{\ensuremath{_{^\vartriangle}}}\emph{#1}}
199+
\leavevmode\marginpar{\ensuremath{\vartriangle}}\emph{#1}}
200200

201201
% Mark a compile-time error in the margin.
202202
\newcommand{\Error}[1]{%
203-
\leavevmode\marginpar{\ensuremath{_{^\ominus}}}{#1}}
203+
\leavevmode\marginpar{\ensuremath{\ominus}}{#1}}
204+
205+
% Mark a dynamic error in the margin.
206+
\newcommand{\DynamicError}[1]{%
207+
\leavevmode\marginpar{\Lightning}{#1}}
204208

205209
% Used to specify comma separated lists of similar symbols.
206210
\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}\\
@@ -116,9 +117,11 @@
116117
% error anyway; change extension names to `typeIdentifier`, avoiding
117118
% built-in identifiers).
118119
%
119-
% Feb 2023
120+
% Jan, Feb 2023
120121
% - Change the specification of constant expressions of the form `e1 == e2`
121122
% to use primitive equality.
123+
% - Introduce `\DynamicError{}`, thus marking every introduction (definition)
124+
% of a dynamic error by a lightning symbol in the right margin.
122125
%
123126
% Dec 2022
124127
% - Change the definition of the type function 'flatten' to resolve soundness
@@ -1635,7 +1638,7 @@ \subsection{Implicitly Induced Getters and Setters}
16351638
will bind \id{} to the object that the argument $x$ is bound to.
16361639
An execution of the setter
16371640
in a situation where the variable \id{} has been bound to an object
1638-
will incur a dynamic error.
1641+
will incur a \DynamicError{dynamic error}.
16391642
\EndCase
16401643

16411644
\LMHash{}%
@@ -4240,7 +4243,7 @@ \subsubsection{Generative Constructors}
42404243
% This can occur due to a failing implicit cast.
42414244
unless the assigned object has a dynamic type
42424245
which is not a subtype of the declared type of the instance variable \id,
4243-
in which case a dynamic error occurs.
4246+
in which case a \DynamicError{dynamic error} occurs.
42444247

42454248
\commentary{%
42464249
The above rule allows initializing formals to be used as optional parameters:%
@@ -10614,7 +10617,7 @@ \subsubsection{Collection Literal Element Evaluation}
1061410617
or the given \code{value} does not have the type \code{Value},
1061510618
but it cannot occur after the pair has been appended to $s$.
1061610619
\item
10617-
Otherwise, a dynamic error occurs.
10620+
Otherwise, a \DynamicError{dynamic error} occurs.
1061810621

1061910622
\commentary{%
1062010623
This occurs when the target is an iterable respectively a map,
@@ -10669,7 +10672,8 @@ \subsubsection{Collection Literal Element Evaluation}
1066910672
and if $\ell_2$ is not present then
1067010673
$\EvaluateElement{\ell} := \LiteralSequence{}$.
1067110674
% $o_b$ can have type \DYNAMIC.
10672-
If $o_b$ is neither \TRUE{} nor \FALSE{} then a dynamic error occurs.
10675+
If $o_b$ is neither \TRUE{} nor \FALSE{}
10676+
then a \DynamicError{dynamic error} occurs.
1067310677
\EndCase
1067410678

1067510679
\LMHash{}%
@@ -10900,7 +10904,7 @@ \subsubsection{Lists}
1090010904
An empty list has an empty set of indices.
1090110905
A non-empty list has the index set $\{0, \ldots, n - 1\}$
1090210906
where $n$ is the size of the list.
10903-
It is a dynamic error to attempt to access a list
10907+
It is a \DynamicError{dynamic error} to attempt to access a list
1090410908
using an index that is not a member of its set of indices.
1090510909

1090610910
\rationale{%
@@ -10924,7 +10928,8 @@ \subsubsection{Lists}
1092410928
Only run-time list literals can be mutated
1092510929
after they are created.
1092610930
% This error can occur because being constant is a dynamic property.
10927-
Attempting to mutate a constant list literal will result in a dynamic error.
10931+
Attempting to mutate a constant list literal
10932+
will result in a \DynamicError{dynamic error}.
1092810933

1092910934
\commentary{%
1093010935
% The following is true either directly or indirectly: There is a \CONST{}
@@ -11702,7 +11707,7 @@ \subsubsection{Sets}
1170211707
\LMHash{}%
1170311708
A set may contain zero or more objects.
1170411709
Sets have a method which can be used to insert objects;
11705-
this will incur a dynamic error if the set is not modifiable.
11710+
this will incur a \DynamicError{dynamic error} if the set is not modifiable.
1170611711
Otherwise, when inserting an object $o_{\metavar{new}}$ into a set $s$,
1170711712
if an object $o_{\metavar{old}}$ exists in $s$ such that
1170811713
\code{$o_{\metavar{old}}$ == $o_{\metavar{new}}$} evaluates to \TRUE{}
@@ -11742,7 +11747,8 @@ \subsubsection{Sets}
1174211747
and it is evaluated at run time.
1174311748
Only run-time set literals can be mutated after they are created.
1174411749
% This error can occur because being constant is a dynamic property, here.
11745-
Attempting to mutate a constant set literal will result in a dynamic error.
11750+
Attempting to mutate a constant set literal
11751+
will result in a \DynamicError{dynamic error}.
1174611752

1174711753
\commentary{%
1174811754
% The following is true either directly or indirectly: There is a \CONST{}
@@ -11950,7 +11956,8 @@ \subsubsection{Maps}
1195011956
and it is evaluated at run time.
1195111957
Only run-time map literals can be mutated after they are created.
1195211958
% This error can occur because being constant is a dynamic property, here.
11953-
Attempting to mutate a constant map literal will result in a dynamic error.
11959+
Attempting to mutate a constant map literal
11960+
will result in a \DynamicError{dynamic error}.
1195411961

1195511962
\commentary{%
1195611963
% The following is true either directly or indirectly: There is a \CONST{}
@@ -12093,7 +12100,8 @@ \subsection{Throw}
1209312100
}
1209412101

1209512102
\LMHash{}%
12096-
If $v$ is the null object (\ref{null}), then a dynamic error occurs.
12103+
If $v$ is the null object (\ref{null})
12104+
then a \DynamicError{dynamic error} occurs.
1209712105
Otherwise let $t$ be a stack trace corresponding to the current execution state,
1209812106
and the \THROW{} statement throws with $v$ as exception object
1209912107
and $t$ as stack trace (\ref{expressionEvaluation}).
@@ -12710,7 +12718,7 @@ \subsubsection{New}
1271012718
% This error can occur because being-loaded is a dynamic property.
1271112719
If $T$ is a deferred type with prefix $p$,
1271212720
then if $p$ has not been successfully loaded,
12713-
a dynamic error occurs.
12721+
a \DynamicError{dynamic error} occurs.
1271412722
\EndCase
1271512723

1271612724
\LMHash{}%
@@ -13639,7 +13647,7 @@ \subsubsection{Binding Actuals to Formals}
1363913647
If $r = 0$ and $s > 0$ then
1364013648
if $f$ does not have default type arguments
1364113649
(\ref{instantiationToBound})
13642-
then a dynamic error occurs.
13650+
then a \DynamicError{dynamic error} occurs.
1364313651
Otherwise replace the actual type argument list:
1364413652
Let $r$ be $s$ and let $t_i$ for $i \in 1 .. s$ be the result of
1364513653
instantiation to bound
@@ -16722,7 +16730,8 @@ \subsection{Assignment}
1672216730
(in which case $v$ has no initializer and is not definitely assigned,
1672316731
or a compile-time error would have occurred)%
1672416732
}.
16725-
If $v$ has previously been bound to an object then a dynamic error occurs.
16733+
If $v$ has previously been bound to an object
16734+
then a \DynamicError{dynamic error} occurs.
1672616735
Otherwise, $v$ is bound to $o$, and then $a$ evaluates to $o$
1672716736
(\ref{expressionEvaluation}).
1672816737
\item
@@ -17275,7 +17284,8 @@ \subsection{Conditional}
1727517284
proceeds as follows:
1727617285
Evaluate $e_1$ to an object $o_1$.
1727717286
% This error can occur due to an implicit cast from \DYNAMIC.
17278-
It is a dynamic error if the run-time type of $o_1$ is not \code{bool}.
17287+
It is a \DynamicError{dynamic error}
17288+
if the run-time type of $o_1$ is not \code{bool}.
1727917289
If $o_1$ is the \TRUE{} object, then the value of $c$ is
1728017290
the result of evaluating the expression $e_2$.
1728117291
Otherwise, the value of $c$ is the result of evaluating the expression $e_3$.
@@ -17343,23 +17353,27 @@ \subsection{Logical Boolean Expressions}
1734317353
\code{$e_1$\,\,||\,\,$e_2$}
1734417354
causes the evaluation of $e_1$ to an object $o_1$.
1734517355
% This error can occur due to an implicit downcast from \DYNAMIC.
17346-
It is a dynamic error if the run-time type of $o_1$ is not \code{bool}.
17356+
It is a \DynamicError{dynamic error}
17357+
if the run-time type of $o_1$ is not \code{bool}.
1734717358
If $o_1$ is \TRUE, the result of evaluating $b$ is \TRUE,
1734817359
otherwise $e_2$ is evaluated to an object $o_2$.
1734917360
% This error can occur due to an implicit downcast from \DYNAMIC.
17350-
It is a dynamic error if the run-time type of $o_2$ is not \code{bool}.
17361+
It is a \DynamicError{dynamic error}
17362+
if the run-time type of $o_2$ is not \code{bool}.
1735117363
Otherwise the result of evaluating $b$ is $o_2$.
1735217364

1735317365
\LMHash{}%
1735417366
Evaluation of a logical boolean expression $b$ of the form
1735517367
\code{$e_1$\,\,\&\&\,\,$e_2$}
1735617368
causes the evaluation of $e_1$ to an object $o_1$.
1735717369
% This error can occur due to an implicit downcast from \DYNAMIC.
17358-
It is a dynamic error if the run-time type of $o_1$ is not \code{bool}.
17370+
It is a \DynamicError{dynamic error}
17371+
if the run-time type of $o_1$ is not \code{bool}.
1735917372
If $o_1$ is \FALSE, the result of evaluating $b$ is \FALSE,
1736017373
otherwise $e_2$ is evaluated to an object $o_2$.
1736117374
% This error can occur due to an implicit downcast from \DYNAMIC.
17362-
It is a dynamic error if the run-time type of $o_2$ is not \code{bool}.
17375+
It is a \DynamicError{dynamic error}
17376+
if the run-time type of $o_2$ is not \code{bool}.
1736317377
Otherwise the result of evaluating $b$ is $o_2$.
1736417378

1736517379

@@ -17955,7 +17969,7 @@ \subsection{Postfix Expressions}
1795517969

1795617970
\LMHash{}%
1795717971
$e$ is evaluated as follows: $e_1$ is evaluated to an object $o$.
17958-
If $o$ is the null object then a dynamic error occurs,
17972+
If $o$ is the null object then a \DynamicError{dynamic error} occurs,
1795917973
otherwise $e$ evaluates to $o$.
1796017974
\EndCase
1796117975

@@ -19307,7 +19321,7 @@ \subsection{Local Variable Declaration}
1930719321
then $v$ is bound to $o$.
1930819322
If an object $o$ is assigned to $v$
1930919323
in a situation where $v$ is bound to an object $o'$
19310-
then a dynamic error occurs
19324+
then a \DynamicError{dynamic error} occurs
1931119325
\commentary{(it does not matter whether $o$ is the same object as $o'$)}.
1931219326

1931319327
\commentary{%
@@ -19468,7 +19482,8 @@ \subsection{If}
1946819482
proceeds as follows:
1946919483
Evaluate the expression $e$ to an object $o$.
1947019484
% This error can occur due to an implicit downcast from \DYNAMIC.
19471-
It is a dynamic error if the run-time type of $o$ is not \code{bool}.
19485+
It is a \DynamicError{dynamic error}
19486+
if the run-time type of $o$ is not \code{bool}.
1947219487
If $o$ is \TRUE, then execute the block statement $S_1$,
1947319488
otherwise execute the block statement $S_2$.
1947419489

@@ -19554,7 +19569,8 @@ \subsubsection{For Loop}
1955419569
\item
1955519570
The expression $[v'/v]c$ is evaluated to an object $o$.
1955619571
% This error can occur due to an implicit downcast from \DYNAMIC.
19557-
It is a dynamic error if the run-time type of $o$ is not \code{bool}.
19572+
It is a \DynamicError{dynamic error}
19573+
if the run-time type of $o$ is not \code{bool}.
1955819574
If $o$ is \FALSE, the for loop completes normally.
1955919575
Otherwise, execution continues at step \ref{beginIteration}.
1956019576
\item
@@ -19767,7 +19783,8 @@ \subsection{While}
1976719783
\LMHash{}%
1976819784
The expression $e$ is evaluated to an object $o$.
1976919785
% This error can occur due to an implicit downcast from \DYNAMIC.
19770-
It is a dynamic error if the run-time type of $o$ is not \code{bool}.
19786+
It is a \DynamicError{dynamic error}
19787+
if the run-time type of $o$ is not \code{bool}.
1977119788

1977219789
\LMHash{}%
1977319790
If $o$ is \FALSE, then execution of the while statement completes normally
@@ -19818,7 +19835,8 @@ \subsection{Do}
1981819835
\LMHash{}%
1981919836
Then, the expression $e$ is evaluated to an object $o$.
1982019837
% This error can occur due to an implicit downcast from \DYNAMIC.
19821-
It is a dynamic error if the run-time type of $o$ is not \code{bool}.
19838+
It is a \DynamicError{dynamic error}
19839+
if the run-time type of $o$ is not \code{bool}.
1982219840
If $o$ is \FALSE, execution of the do statement completes normally
1982319841
(\ref{statementCompletion}).
1982419842
If $o$ is \TRUE, then the do statement is re-executed.
@@ -20576,7 +20594,8 @@ \subsection{Return}
2057620594

2057720595
\LMHash{}%
2057820596
The expression $e$ is evaluated to an object $o$.
20579-
A dynamic error occurs unless the dynamic type of $o$ is a subtype of
20597+
A \DynamicError{dynamic error} occurs
20598+
unless the dynamic type of $o$ is a subtype of
2058020599
the actual return type of $f$
2058120600
(\ref{actualTypes}).
2058220601
Then the return statement $s$ completes returning $o$
@@ -20604,7 +20623,8 @@ \subsection{Return}
2060420623
let \code{v} be a fresh variable bound to $o$ and
2060520624
evaluate \code{\AWAIT{} v} to an object $r$;
2060620625
otherwise let $r$ be $o$.
20607-
A dynamic error occurs unless the dynamic type of $r$
20626+
A \DynamicError{dynamic error} occurs
20627+
unless the dynamic type of $r$
2060820628
is a subtype of the actual value of $T_v$
2060920629
(\ref{actualTypes}).
2061020630
Then the return statement $s$ completes returning $r$
@@ -21506,21 +21526,21 @@ \subsubsection{Semantics of Imports}
2150621526
\NamespaceName{\metavar{import},i},
2150721527
a corresponding getter named \id{} with the same function header as $g$.
2150821528
% This error can occur because being-loaded is a dynamic property.
21509-
Calling the getter results in a dynamic error.
21529+
Calling the getter results in a \DynamicError{dynamic error}.
2151021530
\item
2151121531
For every top level setter $s$ named \code{\id=} in
2151221532
\NamespaceName{\metavar{import},i},
2151321533
a corresponding setter named \code{\id=} with
2151421534
the same function header as $s$.
2151521535
% This error can occur because being-loaded is a dynamic property.
21516-
Calling the setter results in a dynamic error that occurs before
21517-
the actual argument is evaluated.
21536+
Calling the setter results in a \DynamicError{dynamic error}
21537+
that occurs before the actual argument is evaluated.
2151821538
\item
2151921539
For every class, mixin, enum, and type alias declaration named \id{} in
2152021540
\NamespaceName{\metavar{import},i},
2152121541
a corresponding getter named \id{} with return type \code{Type}.
2152221542
% This error can occur because being-loaded is a dynamic property.
21523-
Calling the getter results in a dynamic error.
21543+
Calling the getter results in a \DynamicError{dynamic error}.
2152421544
\end{itemize}
2152521545

2152621546
\rationale{%
@@ -22059,7 +22079,7 @@ \subsection{Scripts}
2205922079
that spawned $i$)%
2206022080
},
2206122081
or the null object if no such object was supplied.
22062-
A dynamic error occurs if
22082+
A \DynamicError{dynamic error} occurs if
2206322083
the run-time type of this object is not a subtype of
2206422084
the declared type of the corresponding parameter of \code{main}.
2206522085
\end{itemize}
@@ -22082,7 +22102,7 @@ \subsection{Scripts}
2208222102
\commentary{%
2208322103
(the above rules ensure that the corresponding parameters are optional)%
2208422104
}.
22085-
But the implementation must ensure that a dynamic error occurs
22105+
But the implementation must ensure that a \DynamicError{dynamic error} occurs
2208622106
if an actual argument does not have a run-time type which is
2208722107
a subtype of the declared type of the parameter.
2208822108

0 commit comments

Comments
 (0)