Skip to content

Commit 76802a5

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

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}\\
@@ -112,9 +113,11 @@
112113
% error anyway; change extension names to `typeIdentifier`, avoiding
113114
% built-in identifiers).
114115
%
115-
% Feb 2023
116+
% Jan, Feb 2023
116117
% - Change the specification of constant expressions of the form `e1 == e2`
117118
% to use primitive equality.
119+
% - Introduce `\DynamicError{}`, thus marking every introduction (definition)
120+
% of a dynamic error by a lightning symbol in the right margin.
118121
%
119122
% Dec 2022
120123
% - Change the definition of the type function 'flatten' to resolve soundness
@@ -1631,7 +1634,7 @@ \subsection{Implicitly Induced Getters and Setters}
16311634
will bind \id{} to the object that the argument $x$ is bound to.
16321635
An execution of the setter
16331636
in a situation where the variable \id{} has been bound to an object
1634-
will incur a dynamic error.
1637+
will incur a \DynamicError{dynamic error}.
16351638
\EndCase
16361639

16371640
\LMHash{}%
@@ -4236,7 +4239,7 @@ \subsubsection{Generative Constructors}
42364239
% This can occur due to a failing implicit cast.
42374240
unless the assigned object has a dynamic type
42384241
which is not a subtype of the declared type of the instance variable \id,
4239-
in which case a dynamic error occurs.
4242+
in which case a \DynamicError{dynamic error} occurs.
42404243

42414244
\commentary{%
42424245
The above rule allows initializing formals to be used as optional parameters:%
@@ -10610,7 +10613,7 @@ \subsubsection{Collection Literal Element Evaluation}
1061010613
or the given \code{value} does not have the type \code{Value},
1061110614
but it cannot occur after the pair has been appended to $s$.
1061210615
\item
10613-
Otherwise, a dynamic error occurs.
10616+
Otherwise, a \DynamicError{dynamic error} occurs.
1061410617

1061510618
\commentary{%
1061610619
This occurs when the target is an iterable respectively a map,
@@ -10665,7 +10668,8 @@ \subsubsection{Collection Literal Element Evaluation}
1066510668
and if $\ell_2$ is not present then
1066610669
$\EvaluateElement{\ell} := \LiteralSequence{}$.
1066710670
% $o_b$ can have type \DYNAMIC.
10668-
If $o_b$ is neither \TRUE{} nor \FALSE{} then a dynamic error occurs.
10671+
If $o_b$ is neither \TRUE{} nor \FALSE{}
10672+
then a \DynamicError{dynamic error} occurs.
1066910673
\EndCase
1067010674

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

1090210906
\rationale{%
@@ -10920,7 +10924,8 @@ \subsubsection{Lists}
1092010924
Only run-time list literals can be mutated
1092110925
after they are created.
1092210926
% This error can occur because being constant is a dynamic property.
10923-
Attempting to mutate a constant list literal will result in a dynamic error.
10927+
Attempting to mutate a constant list literal
10928+
will result in a \DynamicError{dynamic error}.
1092410929

1092510930
\commentary{%
1092610931
% The following is true either directly or indirectly: There is a \CONST{}
@@ -11698,7 +11703,7 @@ \subsubsection{Sets}
1169811703
\LMHash{}%
1169911704
A set may contain zero or more objects.
1170011705
Sets have a method which can be used to insert objects;
11701-
this will incur a dynamic error if the set is not modifiable.
11706+
this will incur a \DynamicError{dynamic error} if the set is not modifiable.
1170211707
Otherwise, when inserting an object $o_{\metavar{new}}$ into a set $s$,
1170311708
if an object $o_{\metavar{old}}$ exists in $s$ such that
1170411709
\code{$o_{\metavar{old}}$ == $o_{\metavar{new}}$} evaluates to \TRUE{}
@@ -11738,7 +11743,8 @@ \subsubsection{Sets}
1173811743
and it is evaluated at run time.
1173911744
Only run-time set literals can be mutated after they are created.
1174011745
% This error can occur because being constant is a dynamic property, here.
11741-
Attempting to mutate a constant set literal will result in a dynamic error.
11746+
Attempting to mutate a constant set literal
11747+
will result in a \DynamicError{dynamic error}.
1174211748

1174311749
\commentary{%
1174411750
% The following is true either directly or indirectly: There is a \CONST{}
@@ -11946,7 +11952,8 @@ \subsubsection{Maps}
1194611952
and it is evaluated at run time.
1194711953
Only run-time map literals can be mutated after they are created.
1194811954
% This error can occur because being constant is a dynamic property, here.
11949-
Attempting to mutate a constant map literal will result in a dynamic error.
11955+
Attempting to mutate a constant map literal
11956+
will result in a \DynamicError{dynamic error}.
1195011957

1195111958
\commentary{%
1195211959
% The following is true either directly or indirectly: There is a \CONST{}
@@ -12089,7 +12096,8 @@ \subsection{Throw}
1208912096
}
1209012097

1209112098
\LMHash{}%
12092-
If $v$ is the null object (\ref{null}), then a dynamic error occurs.
12099+
If $v$ is the null object (\ref{null})
12100+
then a \DynamicError{dynamic error} occurs.
1209312101
Otherwise let $t$ be a stack trace corresponding to the current execution state,
1209412102
and the \THROW{} statement throws with $v$ as exception object
1209512103
and $t$ as stack trace (\ref{expressionEvaluation}).
@@ -12706,7 +12714,7 @@ \subsubsection{New}
1270612714
% This error can occur because being-loaded is a dynamic property.
1270712715
If $T$ is a deferred type with prefix $p$,
1270812716
then if $p$ has not been successfully loaded,
12709-
a dynamic error occurs.
12717+
a \DynamicError{dynamic error} occurs.
1271012718
\EndCase
1271112719

1271212720
\LMHash{}%
@@ -13635,7 +13643,7 @@ \subsubsection{Binding Actuals to Formals}
1363513643
If $r = 0$ and $s > 0$ then
1363613644
if $f$ does not have default type arguments
1363713645
(\ref{instantiationToBound})
13638-
then a dynamic error occurs.
13646+
then a \DynamicError{dynamic error} occurs.
1363913647
Otherwise replace the actual type argument list:
1364013648
Let $r$ be $s$ and let $t_i$ for $i \in 1 .. s$ be the result of
1364113649
instantiation to bound
@@ -16718,7 +16726,8 @@ \subsection{Assignment}
1671816726
(in which case $v$ has no initializer and is not definitely assigned,
1671916727
or a compile-time error would have occurred)%
1672016728
}.
16721-
If $v$ has previously been bound to an object then a dynamic error occurs.
16729+
If $v$ has previously been bound to an object
16730+
then a \DynamicError{dynamic error} occurs.
1672216731
Otherwise, $v$ is bound to $o$, and then $a$ evaluates to $o$
1672316732
(\ref{expressionEvaluation}).
1672416733
\item
@@ -17271,7 +17280,8 @@ \subsection{Conditional}
1727117280
proceeds as follows:
1727217281
Evaluate $e_1$ to an object $o_1$.
1727317282
% This error can occur due to an implicit cast from \DYNAMIC.
17274-
It is a dynamic error if the run-time type of $o_1$ is not \code{bool}.
17283+
It is a \DynamicError{dynamic error}
17284+
if the run-time type of $o_1$ is not \code{bool}.
1727517285
If $o_1$ is the \TRUE{} object, then the value of $c$ is
1727617286
the result of evaluating the expression $e_2$.
1727717287
Otherwise, the value of $c$ is the result of evaluating the expression $e_3$.
@@ -17339,23 +17349,27 @@ \subsection{Logical Boolean Expressions}
1733917349
\code{$e_1$\,\,||\,\,$e_2$}
1734017350
causes the evaluation of $e_1$ to an object $o_1$.
1734117351
% This error can occur due to an implicit downcast from \DYNAMIC.
17342-
It is a dynamic error if the run-time type of $o_1$ is not \code{bool}.
17352+
It is a \DynamicError{dynamic error}
17353+
if the run-time type of $o_1$ is not \code{bool}.
1734317354
If $o_1$ is \TRUE, the result of evaluating $b$ is \TRUE,
1734417355
otherwise $e_2$ is evaluated to an object $o_2$.
1734517356
% This error can occur due to an implicit downcast from \DYNAMIC.
17346-
It is a dynamic error if the run-time type of $o_2$ is not \code{bool}.
17357+
It is a \DynamicError{dynamic error}
17358+
if the run-time type of $o_2$ is not \code{bool}.
1734717359
Otherwise the result of evaluating $b$ is $o_2$.
1734817360

1734917361
\LMHash{}%
1735017362
Evaluation of a logical boolean expression $b$ of the form
1735117363
\code{$e_1$\,\,\&\&\,\,$e_2$}
1735217364
causes the evaluation of $e_1$ to an object $o_1$.
1735317365
% This error can occur due to an implicit downcast from \DYNAMIC.
17354-
It is a dynamic error if the run-time type of $o_1$ is not \code{bool}.
17366+
It is a \DynamicError{dynamic error}
17367+
if the run-time type of $o_1$ is not \code{bool}.
1735517368
If $o_1$ is \FALSE, the result of evaluating $b$ is \FALSE,
1735617369
otherwise $e_2$ is evaluated to an object $o_2$.
1735717370
% This error can occur due to an implicit downcast from \DYNAMIC.
17358-
It is a dynamic error if the run-time type of $o_2$ is not \code{bool}.
17371+
It is a \DynamicError{dynamic error}
17372+
if the run-time type of $o_2$ is not \code{bool}.
1735917373
Otherwise the result of evaluating $b$ is $o_2$.
1736017374

1736117375

@@ -17951,7 +17965,7 @@ \subsection{Postfix Expressions}
1795117965

1795217966
\LMHash{}%
1795317967
$e$ is evaluated as follows: $e_1$ is evaluated to an object $o$.
17954-
If $o$ is the null object then a dynamic error occurs,
17968+
If $o$ is the null object then a \DynamicError{dynamic error} occurs,
1795517969
otherwise $e$ evaluates to $o$.
1795617970
\EndCase
1795717971

@@ -19303,7 +19317,7 @@ \subsection{Local Variable Declaration}
1930319317
then $v$ is bound to $o$.
1930419318
If an object $o$ is assigned to $v$
1930519319
in a situation where $v$ is bound to an object $o'$
19306-
then a dynamic error occurs
19320+
then a \DynamicError{dynamic error} occurs
1930719321
\commentary{(it does not matter whether $o$ is the same object as $o'$)}.
1930819322

1930919323
\commentary{%
@@ -19464,7 +19478,8 @@ \subsection{If}
1946419478
proceeds as follows:
1946519479
Evaluate the expression $e$ to an object $o$.
1946619480
% This error can occur due to an implicit downcast from \DYNAMIC.
19467-
It is a dynamic error if the run-time type of $o$ is not \code{bool}.
19481+
It is a \DynamicError{dynamic error}
19482+
if the run-time type of $o$ is not \code{bool}.
1946819483
If $o$ is \TRUE, then execute the block statement $S_1$,
1946919484
otherwise execute the block statement $S_2$.
1947019485

@@ -19550,7 +19565,8 @@ \subsubsection{For Loop}
1955019565
\item
1955119566
The expression $[v'/v]c$ is evaluated to an object $o$.
1955219567
% This error can occur due to an implicit downcast from \DYNAMIC.
19553-
It is a dynamic error if the run-time type of $o$ is not \code{bool}.
19568+
It is a \DynamicError{dynamic error}
19569+
if the run-time type of $o$ is not \code{bool}.
1955419570
If $o$ is \FALSE, the for loop completes normally.
1955519571
Otherwise, execution continues at step \ref{beginIteration}.
1955619572
\item
@@ -19763,7 +19779,8 @@ \subsection{While}
1976319779
\LMHash{}%
1976419780
The expression $e$ is evaluated to an object $o$.
1976519781
% This error can occur due to an implicit downcast from \DYNAMIC.
19766-
It is a dynamic error if the run-time type of $o$ is not \code{bool}.
19782+
It is a \DynamicError{dynamic error}
19783+
if the run-time type of $o$ is not \code{bool}.
1976719784

1976819785
\LMHash{}%
1976919786
If $o$ is \FALSE, then execution of the while statement completes normally
@@ -19814,7 +19831,8 @@ \subsection{Do}
1981419831
\LMHash{}%
1981519832
Then, the expression $e$ is evaluated to an object $o$.
1981619833
% This error can occur due to an implicit downcast from \DYNAMIC.
19817-
It is a dynamic error if the run-time type of $o$ is not \code{bool}.
19834+
It is a \DynamicError{dynamic error}
19835+
if the run-time type of $o$ is not \code{bool}.
1981819836
If $o$ is \FALSE, execution of the do statement completes normally
1981919837
(\ref{statementCompletion}).
1982019838
If $o$ is \TRUE, then the do statement is re-executed.
@@ -20572,7 +20590,8 @@ \subsection{Return}
2057220590

2057320591
\LMHash{}%
2057420592
The expression $e$ is evaluated to an object $o$.
20575-
A dynamic error occurs unless the dynamic type of $o$ is a subtype of
20593+
A \DynamicError{dynamic error} occurs
20594+
unless the dynamic type of $o$ is a subtype of
2057620595
the actual return type of $f$
2057720596
(\ref{actualTypes}).
2057820597
Then the return statement $s$ completes returning $o$
@@ -20600,7 +20619,8 @@ \subsection{Return}
2060020619
let \code{v} be a fresh variable bound to $o$ and
2060120620
evaluate \code{\AWAIT{} v} to an object $r$;
2060220621
otherwise let $r$ be $o$.
20603-
A dynamic error occurs unless the dynamic type of $r$
20622+
A \DynamicError{dynamic error} occurs
20623+
unless the dynamic type of $r$
2060420624
is a subtype of the actual value of $T_v$
2060520625
(\ref{actualTypes}).
2060620626
Then the return statement $s$ completes returning $r$
@@ -21502,21 +21522,21 @@ \subsubsection{Semantics of Imports}
2150221522
\NamespaceName{\metavar{import},i},
2150321523
a corresponding getter named \id{} with the same function header as $g$.
2150421524
% This error can occur because being-loaded is a dynamic property.
21505-
Calling the getter results in a dynamic error.
21525+
Calling the getter results in a \DynamicError{dynamic error}.
2150621526
\item
2150721527
For every top level setter $s$ named \code{\id=} in
2150821528
\NamespaceName{\metavar{import},i},
2150921529
a corresponding setter named \code{\id=} with
2151021530
the same function header as $s$.
2151121531
% This error can occur because being-loaded is a dynamic property.
21512-
Calling the setter results in a dynamic error that occurs before
21513-
the actual argument is evaluated.
21532+
Calling the setter results in a \DynamicError{dynamic error}
21533+
that occurs before the actual argument is evaluated.
2151421534
\item
2151521535
For every class, mixin, enum, and type alias declaration named \id{} in
2151621536
\NamespaceName{\metavar{import},i},
2151721537
a corresponding getter named \id{} with return type \code{Type}.
2151821538
% This error can occur because being-loaded is a dynamic property.
21519-
Calling the getter results in a dynamic error.
21539+
Calling the getter results in a \DynamicError{dynamic error}.
2152021540
\end{itemize}
2152121541

2152221542
\rationale{%
@@ -22055,7 +22075,7 @@ \subsection{Scripts}
2205522075
that spawned $i$)%
2205622076
},
2205722077
or the null object if no such object was supplied.
22058-
A dynamic error occurs if
22078+
A \DynamicError{dynamic error} occurs if
2205922079
the run-time type of this object is not a subtype of
2206022080
the declared type of the corresponding parameter of \code{main}.
2206122081
\end{itemize}
@@ -22078,7 +22098,7 @@ \subsection{Scripts}
2207822098
\commentary{%
2207922099
(the above rules ensure that the corresponding parameters are optional)%
2208022100
}.
22081-
But the implementation must ensure that a dynamic error occurs
22101+
But the implementation must ensure that a \DynamicError{dynamic error} occurs
2208222102
if an actual argument does not have a run-time type which is
2208322103
a subtype of the declared type of the parameter.
2208422104

0 commit comments

Comments
 (0)