@@ -8647,13 +8647,11 @@ \subsection{Constants}
8647
8647
respectively a constant type expression
8648
8648
if{}f $T$ is a potentially constant type expression
8649
8649
respectively a constant type expression.
8650
- \item
8651
- A type variable is a potentially constant type expression.
8652
8650
\item
8653
8651
%% TODO(eernst): This does not allow for type variables introduced by
8654
8652
%% the type itself. `Function<X>(X)` could be a constant type expression,
8655
8653
%% but that is not covered by the current rules: `X` is a type variable,
8656
- %% and they are never allowed .
8654
+ %% and they are never constant type expressions .
8657
8655
A function type
8658
8656
\code{$R$ Function<\metavar{typeParameters}>(\metavar{parameterTypes})}
8659
8657
(where $R$ and \code{<\metavar{typeParameters}>} may be omitted)
@@ -8663,9 +8661,11 @@ \subsection{Constants}
8663
8661
(if present) contain only potentially constant type expressions
8664
8662
respectively constant type expressions.
8665
8663
\item
8666
- The type \VOID is a potentially constant and a constant type expression.
8664
+ The type \VOID{} is a potentially constant and a constant type expression.
8665
+ \item
8666
+ The type \DYNAMIC{} is a potentially constant and a constant type expression.
8667
8667
\item
8668
- The type \DYNAMIC is a potentially constant and a constant type expression.
8668
+ A type variable is a potentially constant type expression.
8669
8669
\end{itemize}
8670
8670
8671
8671
% Being potentially constant is entirely structural, not type based,
@@ -20568,6 +20568,76 @@ \subsection{Parts}
20568
20568
\subsection{Scripts}
20569
20569
\LMLabel{scripts}
20570
20570
20571
+ \LMHash{}%
20572
+ Let $L$ be a library that exports a declaration $D$ named \code{main}.
20573
+ It is a \Error{compile-time error} unless $D$ is
20574
+ a non-getter function declaration.
20575
+ It is a \Error{compile-time error} if $D$ declares
20576
+ more than two required positional parameters,
20577
+ or if there are any required named parameters.
20578
+ It is a \Error{compile-time error} if $D$ declares
20579
+ at least one positional parameter,
20580
+ and the first positional parameter has a type which is
20581
+ not a supertype of \code{List<String>}.
20582
+
20583
+ \LMHash{}%
20584
+ Implementations are free to impose any additional restrictions on
20585
+ the signature of \code{main}.
20586
+
20587
+ \LMHash{}%
20588
+ A \Index{script} is a library that exports a declaration named \code{main}.
20589
+ A script $L$ is executed as follows:
20590
+
20591
+ \LMHash{}%
20592
+ First, $L$ is compiled as a library as specified above.
20593
+ Then, the top-level function defined by \code{main}
20594
+ in the exported namespace of $L$ is invoked as follows:
20595
+
20596
+ \LMHash{}%
20597
+ If \code{main} can be called with two positional arguments,
20598
+ it is invoked with the following two actual arguments:
20599
+
20600
+ \begin{itemize}
20601
+ \item
20602
+ An object whose run-time type implements \code{List<String>}.
20603
+ \item
20604
+ An object specified when the current isolate $i$ was created,
20605
+ (\commentary{%
20606
+ for example through the invocation of \code{Isolate.spawnUri}
20607
+ that spawned $i$%
20608
+ }),
20609
+ or the null object if no such object was supplied.
20610
+ A dynamic error occurs if
20611
+ the run-time type of this object is not a subtype of
20612
+ the declared type of the corresponding parameter of \code{main}.
20613
+ \end{itemize}
20614
+
20615
+ \LMHash{}%
20616
+ If \code{main} cannot be called with two positional arguments,
20617
+ but it can be called with one positional argument,
20618
+ it is invoked with an object whose run-time type implements \code{List<String>}
20619
+ as the only argument.
20620
+
20621
+ \LMHash{}%
20622
+ If \code{main} cannot be called with one or two positional arguments,
20623
+ it is invoked with no arguments.
20624
+
20625
+ \LMHash{}%
20626
+ In each of the above three cases,
20627
+ an implementation is free to provide additional arguments
20628
+ allowed by the signature of \code{main}
20629
+ (\commentary{%
20630
+ the above rules ensure that the corresponding parameters are optional%
20631
+ }).
20632
+ But the implementation must ensure that a dynamic error occurs
20633
+ if an actual argument does not have a run-time type which is
20634
+ a subtype of the declared type of the parameter.
20635
+
20636
+ \LMHash{}%
20637
+ A Dart program will typically be executed by executing a script.
20638
+ The procedure whereby this script is chosen is implementation specific.
20639
+
20640
+ ----------------------------------------------------------------------
20571
20641
\LMHash{}%
20572
20642
A \Index{script} is a library whose exported namespace (\ref{exports}) includes
20573
20643
a top-level function declaration named \code{main}
@@ -24163,72 +24233,20 @@ \subsubsection{Null promotion}
24163
24233
These are extended as per
24164
24234
[separate proposal](https://github.com/dart-lang/language/blob/master/resources/type-system/flow-analysis.md).
24165
24235
24166
- \subsubsection{The main function }
24236
+ \subsubsection{Runtime type equality operator }
24167
24237
24168
24238
!!!TODO!!!
24169
24239
24170
- The section 'Scripts' in the language specification is replaced by the
24171
- following:
24172
-
24173
- Let $L$ be a library that exports a declaration $D$ named \code{main}.
24174
- It is a \Error{compile-time error} unless $D$ is a non-getter function
24175
- declaration. It is a \Error{compile-time error} if $D$ declares more
24176
- than two required positional parameters, or if there are any required
24177
- named parameters. It is a \Error{compile-time error} if $D$ declares
24178
- at least one positional parameter, and the first positional parameter
24179
- has a type which is not a supertype of \code{List<String>}.
24180
-
24181
- Implementations are free to impose any additional restrictions on the
24182
- signature of \code{main}.
24183
-
24184
- A _script_ is a library that exports a declaration named \code{main}.
24185
- A script $L$ is executed as follows:
24186
-
24187
- First, $L$ is compiled as a library as specified above.
24188
- Then, the top-level function defined by \code{main}
24189
- in the exported namespace of $L$ is invoked as follows:
24190
-
24191
- If \code{main} can be called with two positional arguments,
24192
- it is invoked with the following two actual arguments:
24193
-
24194
- \begin{itemize}
24195
- \item An object whose run-time type implements \code{List<String>}.
24196
- \item An object specified when the current isolate $i$ was created,
24197
- for example through the invocation of \code{Isolate.spawnUri} that spawned $i$,
24198
- or the null object if no such object was supplied.
24199
- A dynamic error occurs if the run-time type of this object is not a
24200
- subtype of the declared type of the corresponding parameter of \code{main}.
24201
- \end{itemize}
24202
-
24203
- If \code{main} cannot be called with two positional arguments, but it can be
24204
- called with one positional argument, it is invoked with an object whose
24205
- run-time type implements \code{List<String>} as the only argument.
24206
-
24207
- If \code{main} cannot be called with one or two positional arguments, it is
24208
- invoked with no arguments.
24209
-
24210
- In each of the above three cases, an implementation is free to provide
24211
- additional arguments allowed by the signature of \code{main}
24212
- (\commentary{the above rules ensure that the corresponding parameters are optional}).
24213
- But the implementation must ensure that a dynamic error occurs if an
24214
- actual argument does not have a run-time type which is a subtype of
24215
- the declared type of the parameter.
24216
-
24217
- A Dart program will typically be executed by executing a script. The
24218
- procedure whereby this script is chosen is implementation specific.
24219
-
24220
- \subsection{Runtime semantics}
24221
-
24222
- \subsubsection{Runtime type equality operator}
24223
-
24224
- Two objects $T_1$ and $T_2$ which are instances of \code{Type} (that is, runtime type
24225
- objects) are considered equal if and only if the runtime type objects $T_1$ and
24226
- $T_2$ corresponds to the types $S_1$ and $S_2$ respectively, and the normal forms
24227
- \NormalizedTypeOf{$S_1$} and \NormalizedTypeOf{$S_2$} are syntactically equal up to equivalence of
24228
- bound variables. Note that we do not equate primitive top types. \code{List<\VOID>}
24229
- and \code{List<\DYNAMIC>} are still considered distinct runtime type objects. Note
24230
- that we also do not equate function
24231
- types which differ in the placement of \REQUIRED{} on parameter types.
24240
+ Two objects $T_1$ and $T_2$ which are instances of \code{Type} (that
24241
+ is, runtime type objects) are considered equal if and only if the
24242
+ runtime type objects $T_1$ and $T_2$ corresponds to the types $S_1$
24243
+ and $S_2$ respectively, and the normal forms \NormalizedTypeOf{$S_1$}
24244
+ and \NormalizedTypeOf{$S_2$} are syntactically equal up to equivalence
24245
+ of bound variables. Note that we do not equate primitive top types.
24246
+ \code{List<\VOID>} and \code{List<\DYNAMIC>} are still considered
24247
+ distinct runtime type objects. Note that we also do not equate
24248
+ function types which differ in the placement of \REQUIRED{} on
24249
+ parameter types.
24232
24250
24233
24251
\subsubsection{Constant evaluation and canonicalization}
24234
24252
0 commit comments