Skip to content

Commit b0bd96c

Browse files
committed
WIP
1 parent a155e97 commit b0bd96c

File tree

2 files changed

+65
-59
lines changed

2 files changed

+65
-59
lines changed

specification/dart.sty

+1-1
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@
456456
\FunctionTypeAllRequired{#1}{ }{X}{B}{s}{T}{n}}
457457

458458
\newcommand{\FunctionTypeNamedStdArgCr}[1]{%
459-
\FunctionTypeNamedArgCr{#1}{ }{X}{B}{s}{T}{n}{x}{k}{r}}
459+
\FunctionTypeNamedArgCr{#1}{ }{X}{B}{s}{T}{n}{x}{k}}
460460

461461
% Same as \FunctionTypeAllRequiredStd except that it includes a newline, hence
462462
% suitable for function types that are too long to fit in one line.

specification/dartLangSpec.tex

+64-58
Original file line numberDiff line numberDiff line change
@@ -21654,9 +21654,6 @@ \subsection{Subtypes}
2165421654
\newcommand{\SrnRightTop}{2}
2165521655
\newcommand{\SrnLeftTop}{3}
2165621656
\newcommand{\SrnBottom}{4}
21657-
%\newcommand{\SrnRightObjectOne}{} Redundant
21658-
%\newcommand{\SrnRightObjectTwo}{} Redundant
21659-
%\newcommand{\SrnRightObjectThree}{} Redundant
2166021657
\newcommand{\SrnRightObjectFour}{5}
2166121658
\newcommand{\SrnNullOne}{6}
2166221659
\newcommand{\SrnNullTwo}{7}
@@ -22267,7 +22264,8 @@ \subsection{Type Nullability}
2226722264
Nullable types are types which are
2226822265
definitively known to include the null object,
2226922266
regardless of the value of any type variables.
22270-
This is equivalent to the syntactic criterion that $T$ is any of:
22267+
If $T'$ is the transitive alias expansion (\ref{typedef}) of $T$
22268+
then this is equivalent to the syntactic criterion that $T'$ is any of:
2227122269

2227222270
\begin{itemize}[itemsep=-0.5ex]
2227322271
\item \VOID.
@@ -22289,7 +22287,8 @@ \subsection{Type Nullability}
2228922287
Non-nullable types are types which are definitively known to
2229022288
\emph{not} include the null object,
2229122289
regardless of the value of any type variables.
22292-
This is equivalent to the syntactic criterion that $T$ is any of:
22290+
If $T'$ is the transitive alias expansion (\ref{typedef}) of $T$
22291+
then this is equivalent to the syntactic criterion that $T$ is any of:
2229322292

2229422293
\begin{itemize}[itemsep=-0.5ex]
2229522294
\item \code{Never}.
@@ -22656,21 +22655,23 @@ \subsection{Type Normalization}
2265622655

2265722656
\noindent
2265822657
then $T_r$ is
22659-
\FunctionTypePositional{R_0}{ }{X}{B}{s}{R}{n}{k}
22658+
\FunctionTypePositional{T'\!_0}{ }{X}{B'\!}{s}{T'\!}{n}{k}
2266022659

2266122660
\noindent
22662-
where $R_i$ is \NormalizedTypeOf{$T_i$} for $i \in 0 .. n+k$.
22661+
where $T'\!_i$ is \NormalizedTypeOf{$T_i$} for $i \in 0 .. n+k$
22662+
and $B'\!_i$ is \NormalizedTypeOf{$B_i$} for $i \in 1 .. s$.
2266322663
\item If $T_u$ is of the form
2266422664
\FunctionTypeNamedStd{T_0}
2266522665

2266622666
\noindent
2266722667
where $r_j$ is either \REQUIRED{} or empty
2266822668
then $T_r$ is
2266922669
\noindent
22670-
\FunctionTypeNamed{R_0}{ }{X}{B}{s}{R}{n}{x}{k}{r}
22670+
\FunctionTypeNamed{T'\!_0}{ }{X}{B'\!}{s}{T'\!}{n}{x}{k}
2267122671

2267222672
\noindent
22673-
where $R_i$ is \NormalizedTypeOf{$T_i$} for $i \in 0 .. n+k$.
22673+
where $T'\!_i$ is \NormalizedTypeOf{$T_i$} for $i \in 0 .. n+k$
22674+
and $B'\!_i$ is \NormalizedTypeOf{$B_i$} for $i \in 0 .. s$.
2267422675
\end{itemize}
2267522676

2267622677
\commentary{%
@@ -23008,8 +23009,8 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
2300823009
which is defined as follows.
2300923010
Assume that $P_1$ and $P_2$ are two formal parameter type declarations
2301023011
with declared type $T_1$ respectively $T_2$,
23011-
such that both are positional or both are named,
23012-
with the same name \DefineSymbol{n}.
23012+
such that both are positional,
23013+
or both are named and have the same name \DefineSymbol{n}.
2301323014
Then \UpperBoundType{$P_1$}{$P_2$} (respectively \LowerBoundType{$P_1$}{$P_2$})
2301423015
is the formal parameter declaration $P$,
2301523016
with the following proporties:
@@ -23028,7 +23029,8 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
2302823029
}
2302923030
\item
2303023031
$P$ is named if $P_1$ and $P_2$ are named.
23031-
In this case, the name of $P$ is $n$.
23032+
In this case, the name of $P$ is $n$
23033+
(\commentary{which is also the name of $P_1$ and $P_2$}).
2303223034
$P$ is marked with the modifier \REQUIRED{}
2303323035
if both $P_1$ and $P_2$ have this modifier
2303423036
(respectively, if either $P_1$ or $P_2$ has this modifier).
@@ -23207,22 +23209,25 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
2320723209

2320823210
\noindent
2320923211
\code{$T_1$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{11}$,\,\ldots,\,$X_m$\,%
23210-
\EXTENDS\,$B_{1m}$>($P_{11}$,\,\ldots,\,$P_{1k}$)}
23212+
\EXTENDS\,$B_{1m}$>($P_{11}$,\,\ldots[\ldots\,$P_{1k}$])}
2321123213

2321223214
\noindent
2321323215
\code{$T_2$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{21}$,\,\ldots,\,$X_m$\,%
23214-
\EXTENDS\,$B_{2m}$>($P_{21}$,\,\ldots,\,$P_{2l}$)}
23216+
\EXTENDS\,$B_{2m}$>($P_{21}$,\,\ldots[\ldots\,$P_{2l}$])}
2321523217

2321623218
\noindent
2321723219
such that each $B_{1i}$ and $B_{2i}$ are types with the same canonical syntax,
23218-
and both have the same number of required positional parameters.
23220+
and both $U_1$ or $U_2$ have
23221+
the same number of required positional parameters.
23222+
In the case where $U_1$ or $U_2$ has no optional positional parameters,
23223+
the brackets are omitted.
2321923224
Let $q$ be $\metavar{min}(k, l)$,
2322023225
let $T_3$ be \UpperBoundType{$T_1$}{$T_2$},
23221-
let $B_{3i}$ be $B_{1i}$, and
23226+
let $B_{3i}$ be $B_{1i}$, and finally
2322223227
let $P_{3i}$ be \LowerBoundType{$P_{1i}$}{$P_{2i}$}.
23223-
Then \DefEquals{\UpperBoundType{$U_1$}{$U_2$}}{%
23228+
Then \DefEqualsNewline{\UpperBoundType{$U_1$}{$U_2$}}{%
2322423229
\code{$T_3$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{31}$,\,\ldots,\,$X_m$\,%
23225-
\EXTENDS\,$B_{3m}$>($P_{31}$,\,\ldots,\,$P_{3q}$)}}.
23230+
\EXTENDS\,$B_{3m}$>($P_{31}$,\,\ldots[\ldots\,$P_{3q}$])}}.
2322623231

2322723232
\commentary{%
2322823233
This case includes non-generic function types by allowing $m$ to be zero.%
@@ -23280,8 +23285,11 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
2328023285
%%
2328123286
%% TODO(eernst), for review: Why do we not have a rule for
2328223287
%% \UpperBoundType{T1 Function(P1..Pm, [...])}{T2 Function(P1..Pk, {...}}}
23283-
%% = T3 Function(R1..Rk), where the left operand has at least k parameters,
23284-
%% plus the converse?
23288+
%% = T3 Function(R1..Rk), where the left operand has at least k parameters
23289+
%% and every named parameter of the right operand is optional (plus the
23290+
%% same rule with operands swapped)?
23291+
%% Motivation: Some expressions of type `Function` would then have a more
23292+
%% precise type, and programs would be safer (a tiny bit, at least).
2328523293
%%
2328623294
\item
2328723295
\DefEquals{\UpperBoundType{$S_1$ \FUNCTION<\ldots>(\ldots)}{%
@@ -23644,7 +23652,7 @@ \subsubsection{The Standard Upper Bound of Distinct Interface Types}
2364423652
$\{\;T\;|\;T\,\in\,M\;\wedge\;\NominalTypeDepth{$T$}\,=\,n\,\}$
2364523653
for any natural number $n$.
2364623654
Let $q$ be the largest number such that $M_q$ has cardinality one.
23647-
Such a number must exist because $M_0$ is $\{\code{Object?}\}$.
23655+
Such a number must exist because $M_0$ is $\{\code{Object}\}$.
2364823656
The least upper bound of $I$ and $J$ is then the sole element of $M_q$.
2364923657

2365023658

@@ -23877,7 +23885,7 @@ \subsection{Least and Greatest Closure of Types}
2387723885
the least closure of $S$ with respect to $L$ is
2387823886

2387923887
\noindent
23880-
\FunctionTypeNamed{U_0}{ }{X}{B}{s}{U}{n}{x}{k}{r}
23888+
\FunctionTypeNamed{U_0}{ }{X}{B}{s}{U}{n}{x}{k}
2388123889

2388223890
\noindent
2388323891
where
@@ -23892,7 +23900,7 @@ \subsection{Least and Greatest Closure of Types}
2389223900
the greatest closure of $S$ with respect to $L$ is
2389323901

2389423902
\noindent
23895-
\FunctionTypeNamed{U_0}{ }{X}{B}{s}{U}{n}{x}{k}{r}
23903+
\FunctionTypeNamed{U_0}{ }{X}{B}{s}{U}{n}{x}{k}
2389623904

2389723905
\noindent
2389823906
where $U_0$ is the greatest closure of $T_0$ with respect to $L$,
@@ -23948,15 +23956,17 @@ \subsection{Types Bounded by Types}
2394823956
\LMLabel{typesBoundedByTypes}
2394923957

2395023958
\LMHash{}%
23951-
For a given type $T_0$, we introduce the notion of a
23952-
\IndexCustom{$T_0$ bounded type}{type!T0 bounded}:
23953-
$T_0$ itself is $T_0$ bounded;
23954-
if $B$ is $T_0$ bounded and
23959+
For a given type $T$, we introduce the notion of a
23960+
% `T bounded` at the end should have been `$T$ bounded`, but makeindex
23961+
% seems to be unable to allow math mode in that position.
23962+
\IndexCustom{$T$ bounded type}{type!T bounded}:
23963+
$T$ itself is $T$ bounded;
23964+
if $B$ is $T$ bounded and
2395523965
$X$ is a type variable with bound $B$
23956-
then $X$ is $T_0$ bounded;
23957-
finally, if $B$ is $T_0$ bounded and
23966+
then $X$ is $T$ bounded;
23967+
finally, if $B$ is $T$ bounded and
2395823968
$X$ is a type variable
23959-
then $X \& B$ is $T_0$ bounded.
23969+
then $X \& B$ is $T$ bounded.
2396023970

2396123971
\LMHash{}%
2396223972
In particular, a
@@ -23970,11 +23980,11 @@ \subsection{Types Bounded by Types}
2397023980
\LMHash{}%
2397123981
A
2397223982
\IndexCustom{function-type bounded type}{type!function-type bounded}
23973-
is a type $T$ which is $T_0$ bounded where $T_0$ is a function type
23983+
is a type $S$ which is $T$ bounded where $T$ is a function type
2397423984
(\ref{functionTypes}).
23975-
A function-type bounded type $T$ has an
23985+
A function-type bounded type $S$ has an
2397623986
\Index{associated function type}
23977-
which is the unique function type $T_0$ such that $T$ is $T_0$ bounded.
23987+
which is the unique function type $T$ such that $S$ is $T$ bounded.
2397823988

2397923989

2398023990
\subsection{Class Building Types}
@@ -24035,7 +24045,7 @@ \subsection{Interface Types}
2403524045
are interface types,
2403624046
and so are
2403724047
\code{Future<$T$>}, \code{Stream<$T$>}, \code{Iterable<$T$>},
24038-
\code{List<$T$>}, \code{Map<$S$,\,\,$T$}, and \code{Set<$T$>},
24048+
\code{List<$T$>}, \code{Map<$S$,\,\,$T$>}, and \code{Set<$T$>},
2403924049
for any $S$ and $T$.%
2404024050
}
2404124051

@@ -24161,8 +24171,13 @@ \subsection{Type Null}
2416124171
\code{Null} is a subtype of all types of the form \code{$T$?},
2416224172
and of all types $S$ such that \futureOrBase{S} is
2416324173
a top type or a type of the form \code{$T$?}.
24164-
The only non-trivial subtypes of \code{Null} are
24165-
\code{Never} and subtypes of \code{Never}
24174+
The only subtypes of \code{Null} are
24175+
other types that contain the null object and no other objects,
24176+
e.g., \code{Null?},
24177+
the empty type,
24178+
i.e., \code{Never} and subtypes of \code{Never},
24179+
and types that could be either,
24180+
e.g., a type variable with bound \code{Null}
2416624181
(\ref{subtypeRules}).%
2416724182
}
2416824183

@@ -24688,22 +24703,10 @@ \subsection{Type Void}
2468824703
\commentary{%
2468924704
The type \VOID{} is a top type
2469024705
(\ref{superBoundedTypes}),
24691-
so \VOID{} and \code{Object} are subtypes of each other
24706+
so \VOID{} and \code{Object?} are subtypes of each other
2469224707
(\ref{subtypes}),
2469324708
which also implies that any object can be
24694-
the value of an expression of type \VOID.
24695-
%
24696-
Consequently, any instance of type \code{Type} which reifies the type \VOID{}
24697-
must compare equal (according to the \lit{==} operator \ref{equality})
24698-
to any instance of \code{Type} which reifies the type \code{Object}
24699-
(\ref{dynamicTypeSystem}).
24700-
It is not guaranteed that \code{identical(\VOID, Object)} evaluates to
24701-
the \TRUE{} object.
24702-
In fact, it is not recommended that implementations strive to achieve this,
24703-
because it may be more important to ensure that diagnostic messages
24704-
(including stack traces and dynamic error messages)
24705-
preserve enough information to use the word `void' when referring to types
24706-
which are specified as such in source code.%
24709+
the value of an expression of type \VOID.%
2470724710
}
2470824711

2470924712
\LMHash{}%
@@ -24841,7 +24844,7 @@ \subsection{Type Void}
2484124844
}
2484224845

2484324846
\begin{dartCode}
24844-
\FOR{} (Object x in <\VOID>[]) \{\} // \comment{Error.}
24847+
\FOR{} (Object? x in <\VOID>[]) \{\} // \comment{Error.}
2484524848
\AWAIT{} \FOR{} (int x \IN{} new Stream<\VOID{}>.empty()) \{\} // \comment{Error.}
2484624849
\FOR{} (\VOID{} x \IN{} <\VOID{}>[]) \{\ldots\} // \comment{OK.}
2484724850
\FOR (\VAR{} x \IN{} <\VOID{}>[]) \{\ldots\} // \comment{OK, type of x inferred.}
@@ -25150,9 +25153,11 @@ \subsection{Definite Assignment}
2515025153
(\commentary{%
2515125154
e.g., as an expression, or as the left hand side of an assignment%
2515225155
}),
25153-
the variable has a status as being
25154-
\IndexCustom{definitely assigned}{local variable!definitely assigned} or
25155-
\IndexCustom{definitely unassigned}{local variable!definitely unassigned}.
25156+
the variable can be
25157+
\IndexCustom{definitely assigned}{local variable!definitely assigned},
25158+
and it can be
25159+
\IndexCustom{definitely unassigned}{local variable!definitely unassigned},
25160+
and it can be neither.
2515625161

2515725162
\commentary{%
2515825163
The precise flow analysis which determines this status at each location
@@ -25405,15 +25410,16 @@ \subsection{Type Promotion}
2540525410

2540625411
%% TODO(eernst), for review: The null safety spec says that `T?` is
2540725412
%% promoted to `T`, but implementations _do_ promote `X extends int?` to
25408-
%% `X & int`. So I've specified the latter. This is also more consistent
25409-
%% with the approach used with `==`.
25413+
%% `X & int`. So we may be able to specify something which will yield
25414+
%% slightly more precise types, and which is more precisely the implemented
25415+
%% behavior.
2541025416
\LMHash{}%
2541125417
A check of the form \code{$v$\,\,!=\,\,\NULL},
2541225418
\code{\NULL\,\,!=\,\,$v$},
2541325419
or \code{$v$\,\,\IS\,\,$T$}
25414-
where $v$ has type $T$ at $\ell$
25420+
where $v$ has static type $T?$ at $\ell$
2541525421
promotes the type of $v$
25416-
to \NonNullType{$T$} in the \TRUE{} continuation,
25422+
to $T$ in the \TRUE{} continuation,
2541725423
and to \code{Null} in the \FALSE{} continuation.
2541825424

2541925425
\commentary{%

0 commit comments

Comments
 (0)