Skip to content

Commit 3711897

Browse files
committed
WIP
1 parent af18d01 commit 3711897

File tree

2 files changed

+69
-63
lines changed

2 files changed

+69
-63
lines changed

specification/dart.sty

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -322,10 +322,10 @@
322322
% Arguments: Return type, spacer, type parameter name, bound name,
323323
% number of type parameters, parameter type, number of required parameters,
324324
% name of optional parameters, number of optional parameters,
325-
% name of `required` symbol.
325+
% The name of `required` symbol is always `r` (can't take 10 parms!!).
326326
\newcommand{\FunctionTypeNamed}[9]{%
327327
\FunctionType{#1}{#2}{#3}{#4}{#5}{\\
328-
\mbox{}\qquad\FunctionTypeNamedArguments{#6}{#7}{#8}{#9}{#10}}}
328+
\mbox{}\qquad\FunctionTypeNamedArguments{#6}{#7}{#8}{#9}{r}}}
329329

330330
% Same as \FunctionType except suitable for inline usage, hence omitting
331331
% the spacer argument.
@@ -347,7 +347,7 @@
347347
\RawFunctionTypePositional{#1}{X}{B}{s}{T}{n}{k}}
348348

349349
\newcommand{\FunctionTypeNamedStd}[1]{%
350-
\FunctionTypeNamed{#1}{ }{X}{B}{s}{T}{n}{x}{k}{r}}
350+
\FunctionTypeNamed{#1}{ }{X}{B}{s}{T}{n}{x}{k}}
351351

352352
\newcommand{\RawFunctionTypeNamedStd}[1]{%
353353
\RawFunctionTypeNamed{#1}{X}{B}{s}{T}{n}{x}{k}{r}}
@@ -359,10 +359,10 @@
359359
\FunctionTypePositional{#1}{\\}{X}{B}{s}{T}{n}{k}}
360360

361361
\newcommand{\FunctionTypeNamedStdCr}[1]{%
362-
\FunctionTypeNamed{#1}{\\}{X}{B}{s}{T}{n}{x}{k}{r}}
362+
\FunctionTypeNamed{#1}{\\}{X}{B}{s}{T}{n}{x}{k}}
363363

364364
\newcommand{\FunctionTypeNamedStdArgCr}[1]{%
365-
\FunctionTypeNamedArgCr{#1}{ }{X}{B}{s}{T}{n}{x}{k}{r}}
365+
\FunctionTypeNamedArgCr{#1}{ }{X}{B}{s}{T}{n}{x}{k}}
366366

367367
\newcommand{\FunctionTypeAllRequiredStdCr}[1]{%
368368
\FunctionTypeAllRequired{#1}{\\}{X}{B}{s}{T}{n}}

specification/dartLangSpec.tex

Lines changed: 64 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -20710,9 +20710,6 @@ \subsection{Subtypes}
2071020710
\newcommand{\SrnRightTop}{2}
2071120711
\newcommand{\SrnLeftTop}{3}
2071220712
\newcommand{\SrnBottom}{4}
20713-
%\newcommand{\SrnRightObjectOne}{} Redundant
20714-
%\newcommand{\SrnRightObjectTwo}{} Redundant
20715-
%\newcommand{\SrnRightObjectThree}{} Redundant
2071620713
\newcommand{\SrnRightObjectFour}{5}
2071720714
\newcommand{\SrnNullOne}{6}
2071820715
\newcommand{\SrnNullTwo}{7}
@@ -21323,7 +21320,8 @@ \subsection{Type Nullability}
2132321320
Nullable types are types which are
2132421321
definitively known to include the null object,
2132521322
regardless of the value of any type variables.
21326-
This is equivalent to the syntactic criterion that $T$ is any of:
21323+
If $T'$ is the transitive alias expansion (\ref{typedef}) of $T$
21324+
then this is equivalent to the syntactic criterion that $T'$ is any of:
2132721325

2132821326
\begin{itemize}[itemsep=-0.5ex]
2132921327
\item \VOID.
@@ -21345,7 +21343,8 @@ \subsection{Type Nullability}
2134521343
Non-nullable types are types which are definitively known to
2134621344
\emph{not} include the null object,
2134721345
regardless of the value of any type variables.
21348-
This is equivalent to the syntactic criterion that $T$ is any of:
21346+
If $T'$ is the transitive alias expansion (\ref{typedef}) of $T$
21347+
then this is equivalent to the syntactic criterion that $T$ is any of:
2134921348

2135021349
\begin{itemize}[itemsep=-0.5ex]
2135121350
\item \code{Never}.
@@ -21712,21 +21711,23 @@ \subsection{Type Normalization}
2171221711

2171321712
\noindent
2171421713
then $T_r$ is
21715-
\FunctionTypePositional{R_0}{ }{X}{B}{s}{R}{n}{k}
21714+
\FunctionTypePositional{T'\!_0}{ }{X}{B'\!}{s}{T'\!}{n}{k}
2171621715

2171721716
\noindent
21718-
where $R_i$ is \NormalizedTypeOf{$T_i$} for $i \in 0 .. n+k$.
21717+
where $T'\!_i$ is \NormalizedTypeOf{$T_i$} for $i \in 0 .. n+k$
21718+
and $B'\!_i$ is \NormalizedTypeOf{$B_i$} for $i \in 1 .. s$.
2171921719
\item If $T_u$ is of the form
2172021720
\FunctionTypeNamedStd{T_0}
2172121721

2172221722
\noindent
2172321723
where $r_j$ is either \REQUIRED{} or empty
2172421724
then $T_r$ is
2172521725
\noindent
21726-
\FunctionTypeNamed{R_0}{ }{X}{B}{s}{R}{n}{x}{k}{r}
21726+
\FunctionTypeNamed{T'\!_0}{ }{X}{B'\!}{s}{T'\!}{n}{x}{k}
2172721727

2172821728
\noindent
21729-
where $R_i$ is \NormalizedTypeOf{$T_i$} for $i \in 0 .. n+k$.
21729+
where $T'\!_i$ is \NormalizedTypeOf{$T_i$} for $i \in 0 .. n+k$
21730+
and $B'\!_i$ is \NormalizedTypeOf{$B_i$} for $i \in 0 .. s$.
2173021731
\end{itemize}
2173121732

2173221733
\commentary{%
@@ -22064,8 +22065,8 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
2206422065
which is defined as follows.
2206522066
Assume that $P_1$ and $P_2$ are two formal parameter type declarations
2206622067
with declared type $T_1$ respectively $T_2$,
22067-
such that both are positional or both are named,
22068-
with the same name \DefineSymbol{n}.
22068+
such that both are positional,
22069+
or both are named and have the same name \DefineSymbol{n}.
2206922070
Then \UpperBoundType{$P_1$}{$P_2$} (respectively \LowerBoundType{$P_1$}{$P_2$})
2207022071
is the formal parameter declaration $P$,
2207122072
with the following proporties:
@@ -22084,7 +22085,8 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
2208422085
}
2208522086
\item
2208622087
$P$ is named if $P_1$ and $P_2$ are named.
22087-
In this case, the name of $P$ is $n$.
22088+
In this case, the name of $P$ is $n$
22089+
(\commentary{which is also the name of $P_1$ and $P_2$}).
2208822090
$P$ is marked with the modifier \REQUIRED{}
2208922091
if both $P_1$ and $P_2$ have this modifier
2209022092
(respectively, if either $P_1$ or $P_2$ has this modifier).
@@ -22263,22 +22265,25 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
2226322265

2226422266
\noindent
2226522267
\code{$T_1$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{11}$,\,\ldots,\,$X_m$\,%
22266-
\EXTENDS\,$B_{1m}$>($P_{11}$,\,\ldots,\,$P_{1k}$)}
22268+
\EXTENDS\,$B_{1m}$>($P_{11}$,\,\ldots[\ldots\,$P_{1k}$])}
2226722269

2226822270
\noindent
2226922271
\code{$T_2$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{21}$,\,\ldots,\,$X_m$\,%
22270-
\EXTENDS\,$B_{2m}$>($P_{21}$,\,\ldots,\,$P_{2l}$)}
22272+
\EXTENDS\,$B_{2m}$>($P_{21}$,\,\ldots[\ldots\,$P_{2l}$])}
2227122273

2227222274
\noindent
2227322275
such that each $B_{1i}$ and $B_{2i}$ are types with the same canonical syntax,
22274-
and both have the same number of required positional parameters.
22276+
and both $U_1$ or $U_2$ have
22277+
the same number of required positional parameters.
22278+
In the case where $U_1$ or $U_2$ has no optional positional parameters,
22279+
the brackets are omitted.
2227522280
Let $q$ be $\metavar{min}(k, l)$,
2227622281
let $T_3$ be \UpperBoundType{$T_1$}{$T_2$},
22277-
let $B_{3i}$ be $B_{1i}$, and
22282+
let $B_{3i}$ be $B_{1i}$, and finally
2227822283
let $P_{3i}$ be \LowerBoundType{$P_{1i}$}{$P_{2i}$}.
22279-
Then \DefEquals{\UpperBoundType{$U_1$}{$U_2$}}{%
22284+
Then \DefEqualsNewline{\UpperBoundType{$U_1$}{$U_2$}}{%
2228022285
\code{$T_3$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{31}$,\,\ldots,\,$X_m$\,%
22281-
\EXTENDS\,$B_{3m}$>($P_{31}$,\,\ldots,\,$P_{3q}$)}}.
22286+
\EXTENDS\,$B_{3m}$>($P_{31}$,\,\ldots[\ldots\,$P_{3q}$])}}.
2228222287

2228322288
\commentary{%
2228422289
This case includes non-generic function types by allowing $m$ to be zero.%
@@ -22336,8 +22341,11 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
2233622341
%%
2233722342
%% TODO(eernst), for review: Why do we not have a rule for
2233822343
%% \UpperBoundType{T1 Function(P1..Pm, [...])}{T2 Function(P1..Pk, {...}}}
22339-
%% = T3 Function(R1..Rk), where the left operand has at least k parameters,
22340-
%% plus the converse?
22344+
%% = T3 Function(R1..Rk), where the left operand has at least k parameters
22345+
%% and every named parameter of the right operand is optional (plus the
22346+
%% same rule with operands swapped)?
22347+
%% Motivation: Some expressions of type `Function` would then have a more
22348+
%% precise type, and programs would be safer (a tiny bit, at least).
2234122349
%%
2234222350
\item
2234322351
\DefEquals{\UpperBoundType{$S_1$ \FUNCTION<\ldots>(\ldots)}{%
@@ -22700,7 +22708,7 @@ \subsubsection{The Standard Upper Bound of Distinct Interface Types}
2270022708
$\{\;T\;|\;T\,\in\,M\;\wedge\;\NominalTypeDepth{$T$}\,=\,n\,\}$
2270122709
for any natural number $n$.
2270222710
Let $q$ be the largest number such that $M_q$ has cardinality one.
22703-
Such a number must exist because $M_0$ is $\{\code{Object?}\}$.
22711+
Such a number must exist because $M_0$ is $\{\code{Object}\}$.
2270422712
The least upper bound of $I$ and $J$ is then the sole element of $M_q$.
2270522713

2270622714

@@ -22933,7 +22941,7 @@ \subsection{Least and Greatest Closure of Types}
2293322941
the least closure of $S$ with respect to $L$ is
2293422942

2293522943
\noindent
22936-
\FunctionTypeNamed{U_0}{ }{X}{B}{s}{U}{n}{x}{k}{r}
22944+
\FunctionTypeNamed{U_0}{ }{X}{B}{s}{U}{n}{x}{k}
2293722945

2293822946
\noindent
2293922947
where
@@ -22948,7 +22956,7 @@ \subsection{Least and Greatest Closure of Types}
2294822956
the greatest closure of $S$ with respect to $L$ is
2294922957

2295022958
\noindent
22951-
\FunctionTypeNamed{U_0}{ }{X}{B}{s}{U}{n}{x}{k}{r}
22959+
\FunctionTypeNamed{U_0}{ }{X}{B}{s}{U}{n}{x}{k}
2295222960

2295322961
\noindent
2295422962
where $U_0$ is the greatest closure of $T_0$ with respect to $L$,
@@ -23004,15 +23012,17 @@ \subsection{Types Bounded by Types}
2300423012
\LMLabel{typesBoundedByTypes}
2300523013

2300623014
\LMHash{}%
23007-
For a given type $T_0$, we introduce the notion of a
23008-
\IndexCustom{$T_0$ bounded type}{type!T0 bounded}:
23009-
$T_0$ itself is $T_0$ bounded;
23010-
if $B$ is $T_0$ bounded and
23015+
For a given type $T$, we introduce the notion of a
23016+
% `T bounded` at the end should have been `$T$ bounded`, but makeindex
23017+
% seems to be unable to allow math mode in that position.
23018+
\IndexCustom{$T$ bounded type}{type!T bounded}:
23019+
$T$ itself is $T$ bounded;
23020+
if $B$ is $T$ bounded and
2301123021
$X$ is a type variable with bound $B$
23012-
then $X$ is $T_0$ bounded;
23013-
finally, if $B$ is $T_0$ bounded and
23022+
then $X$ is $T$ bounded;
23023+
finally, if $B$ is $T$ bounded and
2301423024
$X$ is a type variable
23015-
then $X \& B$ is $T_0$ bounded.
23025+
then $X \& B$ is $T$ bounded.
2301623026

2301723027
\LMHash{}%
2301823028
In particular, a
@@ -23026,11 +23036,11 @@ \subsection{Types Bounded by Types}
2302623036
\LMHash{}%
2302723037
A
2302823038
\IndexCustom{function-type bounded type}{type!function-type bounded}
23029-
is a type $T$ which is $T_0$ bounded where $T_0$ is a function type
23039+
is a type $S$ which is $T$ bounded where $T$ is a function type
2303023040
(\ref{functionTypes}).
23031-
A function-type bounded type $T$ has an
23041+
A function-type bounded type $S$ has an
2303223042
\Index{associated function type}
23033-
which is the unique function type $T_0$ such that $T$ is $T_0$ bounded.
23043+
which is the unique function type $T$ such that $S$ is $T$ bounded.
2303423044

2303523045

2303623046
\subsection{Class Building Types}
@@ -23091,7 +23101,7 @@ \subsection{Interface Types}
2309123101
are interface types,
2309223102
and so are
2309323103
\code{Future<$T$>}, \code{Stream<$T$>}, \code{Iterable<$T$>},
23094-
\code{List<$T$>}, \code{Map<$S$,\,\,$T$}, and \code{Set<$T$>},
23104+
\code{List<$T$>}, \code{Map<$S$,\,\,$T$>}, and \code{Set<$T$>},
2309523105
for any $S$ and $T$.%
2309623106
}
2309723107

@@ -23217,8 +23227,13 @@ \subsection{Type Null}
2321723227
\code{Null} is a subtype of all types of the form \code{$T$?},
2321823228
and of all types $S$ such that \futureOrBase{S} is
2321923229
a top type or a type of the form \code{$T$?}.
23220-
The only non-trivial subtypes of \code{Null} are
23221-
\code{Never} and subtypes of \code{Never}
23230+
The only subtypes of \code{Null} are
23231+
other types that contain the null object and no other objects,
23232+
e.g., \code{Null?},
23233+
the empty type,
23234+
i.e., \code{Never} and subtypes of \code{Never},
23235+
and types that could be either,
23236+
e.g., a type variable with bound \code{Null}
2322223237
(\ref{subtypeRules}).%
2322323238
}
2322423239

@@ -23744,22 +23759,10 @@ \subsection{Type Void}
2374423759
\commentary{%
2374523760
The type \VOID{} is a top type
2374623761
(\ref{superBoundedTypes}),
23747-
so \VOID{} and \code{Object} are subtypes of each other
23762+
so \VOID{} and \code{Object?} are subtypes of each other
2374823763
(\ref{subtypes}),
2374923764
which also implies that any object can be
23750-
the value of an expression of type \VOID.
23751-
%
23752-
Consequently, any instance of type \code{Type} which reifies the type \VOID{}
23753-
must compare equal (according to the \lit{==} operator \ref{equality})
23754-
to any instance of \code{Type} which reifies the type \code{Object}
23755-
(\ref{dynamicTypeSystem}).
23756-
It is not guaranteed that \code{identical(\VOID, Object)} evaluates to
23757-
the \TRUE{} object.
23758-
In fact, it is not recommended that implementations strive to achieve this,
23759-
because it may be more important to ensure that diagnostic messages
23760-
(including stack traces and dynamic error messages)
23761-
preserve enough information to use the word `void' when referring to types
23762-
which are specified as such in source code.%
23765+
the value of an expression of type \VOID.%
2376323766
}
2376423767

2376523768
\LMHash{}%
@@ -23897,7 +23900,7 @@ \subsection{Type Void}
2389723900
}
2389823901

2389923902
\begin{dartCode}
23900-
\FOR{} (Object x in <\VOID>[]) \{\} // \comment{Error.}
23903+
\FOR{} (Object? x in <\VOID>[]) \{\} // \comment{Error.}
2390123904
\AWAIT{} \FOR{} (int x \IN{} new Stream<\VOID{}>.empty()) \{\} // \comment{Error.}
2390223905
\FOR{} (\VOID{} x \IN{} <\VOID{}>[]) \{\ldots\} // \comment{OK.}
2390323906
\FOR (\VAR{} x \IN{} <\VOID{}>[]) \{\ldots\} // \comment{OK, type of x inferred.}
@@ -24206,9 +24209,11 @@ \subsection{Definite Assignment}
2420624209
(\commentary{%
2420724210
e.g., as an expression, or as the left hand side of an assignment%
2420824211
}),
24209-
the variable has a status as being
24210-
\IndexCustom{definitely assigned}{local variable!definitely assigned} or
24211-
\IndexCustom{definitely unassigned}{local variable!definitely unassigned}.
24212+
the variable can be
24213+
\IndexCustom{definitely assigned}{local variable!definitely assigned},
24214+
and it can be
24215+
\IndexCustom{definitely unassigned}{local variable!definitely unassigned},
24216+
and it can be neither.
2421224217

2421324218
\commentary{%
2421424219
The precise flow analysis which determines this status at each location
@@ -24461,15 +24466,16 @@ \subsection{Type Promotion}
2446124466

2446224467
%% TODO(eernst), for review: The null safety spec says that `T?` is
2446324468
%% promoted to `T`, but implementations _do_ promote `X extends int?` to
24464-
%% `X & int`. So I've specified the latter. This is also more consistent
24465-
%% with the approach used with `==`.
24469+
%% `X & int`. So we may be able to specify something which will yield
24470+
%% slightly more precise types, and which is more precisely the implemented
24471+
%% behavior.
2446624472
\LMHash{}%
2446724473
A check of the form \code{$v$\,\,!=\,\,\NULL},
2446824474
\code{\NULL\,\,!=\,\,$v$},
2446924475
or \code{$v$\,\,\IS\,\,$T$}
24470-
where $v$ has type $T$ at $\ell$
24476+
where $v$ has static type $T?$ at $\ell$
2447124477
promotes the type of $v$
24472-
to \NonNullType{$T$} in the \TRUE{} continuation,
24478+
to $T$ in the \TRUE{} continuation,
2447324479
and to \code{Null} in the \FALSE{} continuation.
2447424480

2447524481
\commentary{%

0 commit comments

Comments
 (0)