Skip to content

Commit f46b420

Browse files
committed
WIP
1 parent de2aa9b commit f46b420

File tree

2 files changed

+69
-63
lines changed

2 files changed

+69
-63
lines changed

specification/dart.sty

+5-5
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

+64-58
Original file line numberDiff line numberDiff line change
@@ -20689,9 +20689,6 @@ \subsection{Subtypes}
2068920689
\newcommand{\SrnRightTop}{2}
2069020690
\newcommand{\SrnLeftTop}{3}
2069120691
\newcommand{\SrnBottom}{4}
20692-
%\newcommand{\SrnRightObjectOne}{} Redundant
20693-
%\newcommand{\SrnRightObjectTwo}{} Redundant
20694-
%\newcommand{\SrnRightObjectThree}{} Redundant
2069520692
\newcommand{\SrnRightObjectFour}{5}
2069620693
\newcommand{\SrnNullOne}{6}
2069720694
\newcommand{\SrnNullTwo}{7}
@@ -21302,7 +21299,8 @@ \subsection{Type Nullability}
2130221299
Nullable types are types which are
2130321300
definitively known to include the null object,
2130421301
regardless of the value of any type variables.
21305-
This is equivalent to the syntactic criterion that $T$ is any of:
21302+
If $T'$ is the transitive alias expansion (\ref{typedef}) of $T$
21303+
then this is equivalent to the syntactic criterion that $T'$ is any of:
2130621304

2130721305
\begin{itemize}[itemsep=-0.5ex]
2130821306
\item \VOID.
@@ -21324,7 +21322,8 @@ \subsection{Type Nullability}
2132421322
Non-nullable types are types which are definitively known to
2132521323
\emph{not} include the null object,
2132621324
regardless of the value of any type variables.
21327-
This is equivalent to the syntactic criterion that $T$ is any of:
21325+
If $T'$ is the transitive alias expansion (\ref{typedef}) of $T$
21326+
then this is equivalent to the syntactic criterion that $T$ is any of:
2132821327

2132921328
\begin{itemize}[itemsep=-0.5ex]
2133021329
\item \code{Never}.
@@ -21691,21 +21690,23 @@ \subsection{Type Normalization}
2169121690

2169221691
\noindent
2169321692
then $T_r$ is
21694-
\FunctionTypePositional{R_0}{ }{X}{B}{s}{R}{n}{k}
21693+
\FunctionTypePositional{T'\!_0}{ }{X}{B'\!}{s}{T'\!}{n}{k}
2169521694

2169621695
\noindent
21697-
where $R_i$ is \NormalizedTypeOf{$T_i$} for $i \in 0 .. n+k$.
21696+
where $T'\!_i$ is \NormalizedTypeOf{$T_i$} for $i \in 0 .. n+k$
21697+
and $B'\!_i$ is \NormalizedTypeOf{$B_i$} for $i \in 1 .. s$.
2169821698
\item If $T_u$ is of the form
2169921699
\FunctionTypeNamedStd{T_0}
2170021700

2170121701
\noindent
2170221702
where $r_j$ is either \REQUIRED{} or empty
2170321703
then $T_r$ is
2170421704
\noindent
21705-
\FunctionTypeNamed{R_0}{ }{X}{B}{s}{R}{n}{x}{k}{r}
21705+
\FunctionTypeNamed{T'\!_0}{ }{X}{B'\!}{s}{T'\!}{n}{x}{k}
2170621706

2170721707
\noindent
21708-
where $R_i$ is \NormalizedTypeOf{$T_i$} for $i \in 0 .. n+k$.
21708+
where $T'\!_i$ is \NormalizedTypeOf{$T_i$} for $i \in 0 .. n+k$
21709+
and $B'\!_i$ is \NormalizedTypeOf{$B_i$} for $i \in 0 .. s$.
2170921710
\end{itemize}
2171021711

2171121712
\commentary{%
@@ -22043,8 +22044,8 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
2204322044
which is defined as follows.
2204422045
Assume that $P_1$ and $P_2$ are two formal parameter type declarations
2204522046
with declared type $T_1$ respectively $T_2$,
22046-
such that both are positional or both are named,
22047-
with the same name \DefineSymbol{n}.
22047+
such that both are positional,
22048+
or both are named and have the same name \DefineSymbol{n}.
2204822049
Then \UpperBoundType{$P_1$}{$P_2$} (respectively \LowerBoundType{$P_1$}{$P_2$})
2204922050
is the formal parameter declaration $P$,
2205022051
with the following proporties:
@@ -22063,7 +22064,8 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
2206322064
}
2206422065
\item
2206522066
$P$ is named if $P_1$ and $P_2$ are named.
22066-
In this case, the name of $P$ is $n$.
22067+
In this case, the name of $P$ is $n$
22068+
(\commentary{which is also the name of $P_1$ and $P_2$}).
2206722069
$P$ is marked with the modifier \REQUIRED{}
2206822070
if both $P_1$ and $P_2$ have this modifier
2206922071
(respectively, if either $P_1$ or $P_2$ has this modifier).
@@ -22242,22 +22244,25 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
2224222244

2224322245
\noindent
2224422246
\code{$T_1$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{11}$,\,\ldots,\,$X_m$\,%
22245-
\EXTENDS\,$B_{1m}$>($P_{11}$,\,\ldots,\,$P_{1k}$)}
22247+
\EXTENDS\,$B_{1m}$>($P_{11}$,\,\ldots[\ldots\,$P_{1k}$])}
2224622248

2224722249
\noindent
2224822250
\code{$T_2$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{21}$,\,\ldots,\,$X_m$\,%
22249-
\EXTENDS\,$B_{2m}$>($P_{21}$,\,\ldots,\,$P_{2l}$)}
22251+
\EXTENDS\,$B_{2m}$>($P_{21}$,\,\ldots[\ldots\,$P_{2l}$])}
2225022252

2225122253
\noindent
2225222254
such that each $B_{1i}$ and $B_{2i}$ are types with the same canonical syntax,
22253-
and both have the same number of required positional parameters.
22255+
and both $U_1$ or $U_2$ have
22256+
the same number of required positional parameters.
22257+
In the case where $U_1$ or $U_2$ has no optional positional parameters,
22258+
the brackets are omitted.
2225422259
Let $q$ be $\metavar{min}(k, l)$,
2225522260
let $T_3$ be \UpperBoundType{$T_1$}{$T_2$},
22256-
let $B_{3i}$ be $B_{1i}$, and
22261+
let $B_{3i}$ be $B_{1i}$, and finally
2225722262
let $P_{3i}$ be \LowerBoundType{$P_{1i}$}{$P_{2i}$}.
22258-
Then \DefEquals{\UpperBoundType{$U_1$}{$U_2$}}{%
22263+
Then \DefEqualsNewline{\UpperBoundType{$U_1$}{$U_2$}}{%
2225922264
\code{$T_3$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{31}$,\,\ldots,\,$X_m$\,%
22260-
\EXTENDS\,$B_{3m}$>($P_{31}$,\,\ldots,\,$P_{3q}$)}}.
22265+
\EXTENDS\,$B_{3m}$>($P_{31}$,\,\ldots[\ldots\,$P_{3q}$])}}.
2226122266

2226222267
\commentary{%
2226322268
This case includes non-generic function types by allowing $m$ to be zero.%
@@ -22315,8 +22320,11 @@ \subsection{Standard Upper Bounds and Standard Lower Bounds}
2231522320
%%
2231622321
%% TODO(eernst), for review: Why do we not have a rule for
2231722322
%% \UpperBoundType{T1 Function(P1..Pm, [...])}{T2 Function(P1..Pk, {...}}}
22318-
%% = T3 Function(R1..Rk), where the left operand has at least k parameters,
22319-
%% plus the converse?
22323+
%% = T3 Function(R1..Rk), where the left operand has at least k parameters
22324+
%% and every named parameter of the right operand is optional (plus the
22325+
%% same rule with operands swapped)?
22326+
%% Motivation: Some expressions of type `Function` would then have a more
22327+
%% precise type, and programs would be safer (a tiny bit, at least).
2232022328
%%
2232122329
\item
2232222330
\DefEquals{\UpperBoundType{$S_1$ \FUNCTION<\ldots>(\ldots)}{%
@@ -22679,7 +22687,7 @@ \subsubsection{The Standard Upper Bound of Distinct Interface Types}
2267922687
$\{\;T\;|\;T\,\in\,M\;\wedge\;\NominalTypeDepth{$T$}\,=\,n\,\}$
2268022688
for any natural number $n$.
2268122689
Let $q$ be the largest number such that $M_q$ has cardinality one.
22682-
Such a number must exist because $M_0$ is $\{\code{Object?}\}$.
22690+
Such a number must exist because $M_0$ is $\{\code{Object}\}$.
2268322691
The least upper bound of $I$ and $J$ is then the sole element of $M_q$.
2268422692

2268522693

@@ -22912,7 +22920,7 @@ \subsection{Least and Greatest Closure of Types}
2291222920
the least closure of $S$ with respect to $L$ is
2291322921

2291422922
\noindent
22915-
\FunctionTypeNamed{U_0}{ }{X}{B}{s}{U}{n}{x}{k}{r}
22923+
\FunctionTypeNamed{U_0}{ }{X}{B}{s}{U}{n}{x}{k}
2291622924

2291722925
\noindent
2291822926
where
@@ -22927,7 +22935,7 @@ \subsection{Least and Greatest Closure of Types}
2292722935
the greatest closure of $S$ with respect to $L$ is
2292822936

2292922937
\noindent
22930-
\FunctionTypeNamed{U_0}{ }{X}{B}{s}{U}{n}{x}{k}{r}
22938+
\FunctionTypeNamed{U_0}{ }{X}{B}{s}{U}{n}{x}{k}
2293122939

2293222940
\noindent
2293322941
where $U_0$ is the greatest closure of $T_0$ with respect to $L$,
@@ -22983,15 +22991,17 @@ \subsection{Types Bounded by Types}
2298322991
\LMLabel{typesBoundedByTypes}
2298422992

2298522993
\LMHash{}%
22986-
For a given type $T_0$, we introduce the notion of a
22987-
\IndexCustom{$T_0$ bounded type}{type!T0 bounded}:
22988-
$T_0$ itself is $T_0$ bounded;
22989-
if $B$ is $T_0$ bounded and
22994+
For a given type $T$, we introduce the notion of a
22995+
% `T bounded` at the end should have been `$T$ bounded`, but makeindex
22996+
% seems to be unable to allow math mode in that position.
22997+
\IndexCustom{$T$ bounded type}{type!T bounded}:
22998+
$T$ itself is $T$ bounded;
22999+
if $B$ is $T$ bounded and
2299023000
$X$ is a type variable with bound $B$
22991-
then $X$ is $T_0$ bounded;
22992-
finally, if $B$ is $T_0$ bounded and
23001+
then $X$ is $T$ bounded;
23002+
finally, if $B$ is $T$ bounded and
2299323003
$X$ is a type variable
22994-
then $X \& B$ is $T_0$ bounded.
23004+
then $X \& B$ is $T$ bounded.
2299523005

2299623006
\LMHash{}%
2299723007
In particular, a
@@ -23005,11 +23015,11 @@ \subsection{Types Bounded by Types}
2300523015
\LMHash{}%
2300623016
A
2300723017
\IndexCustom{function-type bounded type}{type!function-type bounded}
23008-
is a type $T$ which is $T_0$ bounded where $T_0$ is a function type
23018+
is a type $S$ which is $T$ bounded where $T$ is a function type
2300923019
(\ref{functionTypes}).
23010-
A function-type bounded type $T$ has an
23020+
A function-type bounded type $S$ has an
2301123021
\Index{associated function type}
23012-
which is the unique function type $T_0$ such that $T$ is $T_0$ bounded.
23022+
which is the unique function type $T$ such that $S$ is $T$ bounded.
2301323023

2301423024

2301523025
\subsection{Class Building Types}
@@ -23070,7 +23080,7 @@ \subsection{Interface Types}
2307023080
are interface types,
2307123081
and so are
2307223082
\code{Future<$T$>}, \code{Stream<$T$>}, \code{Iterable<$T$>},
23073-
\code{List<$T$>}, \code{Map<$S$,\,\,$T$}, and \code{Set<$T$>},
23083+
\code{List<$T$>}, \code{Map<$S$,\,\,$T$>}, and \code{Set<$T$>},
2307423084
for any $S$ and $T$.%
2307523085
}
2307623086

@@ -23196,8 +23206,13 @@ \subsection{Type Null}
2319623206
\code{Null} is a subtype of all types of the form \code{$T$?},
2319723207
and of all types $S$ such that \futureOrBase{S} is
2319823208
a top type or a type of the form \code{$T$?}.
23199-
The only non-trivial subtypes of \code{Null} are
23200-
\code{Never} and subtypes of \code{Never}
23209+
The only subtypes of \code{Null} are
23210+
other types that contain the null object and no other objects,
23211+
e.g., \code{Null?},
23212+
the empty type,
23213+
i.e., \code{Never} and subtypes of \code{Never},
23214+
and types that could be either,
23215+
e.g., a type variable with bound \code{Null}
2320123216
(\ref{subtypeRules}).%
2320223217
}
2320323218

@@ -23723,22 +23738,10 @@ \subsection{Type Void}
2372323738
\commentary{%
2372423739
The type \VOID{} is a top type
2372523740
(\ref{superBoundedTypes}),
23726-
so \VOID{} and \code{Object} are subtypes of each other
23741+
so \VOID{} and \code{Object?} are subtypes of each other
2372723742
(\ref{subtypes}),
2372823743
which also implies that any object can be
23729-
the value of an expression of type \VOID.
23730-
%
23731-
Consequently, any instance of type \code{Type} which reifies the type \VOID{}
23732-
must compare equal (according to the \lit{==} operator \ref{equality})
23733-
to any instance of \code{Type} which reifies the type \code{Object}
23734-
(\ref{dynamicTypeSystem}).
23735-
It is not guaranteed that \code{identical(\VOID, Object)} evaluates to
23736-
the \TRUE{} object.
23737-
In fact, it is not recommended that implementations strive to achieve this,
23738-
because it may be more important to ensure that diagnostic messages
23739-
(including stack traces and dynamic error messages)
23740-
preserve enough information to use the word `void' when referring to types
23741-
which are specified as such in source code.%
23744+
the value of an expression of type \VOID.%
2374223745
}
2374323746

2374423747
\LMHash{}%
@@ -23876,7 +23879,7 @@ \subsection{Type Void}
2387623879
}
2387723880

2387823881
\begin{dartCode}
23879-
\FOR{} (Object x in <\VOID>[]) \{\} // \comment{Error.}
23882+
\FOR{} (Object? x in <\VOID>[]) \{\} // \comment{Error.}
2388023883
\AWAIT{} \FOR{} (int x \IN{} new Stream<\VOID{}>.empty()) \{\} // \comment{Error.}
2388123884
\FOR{} (\VOID{} x \IN{} <\VOID{}>[]) \{\ldots\} // \comment{OK.}
2388223885
\FOR (\VAR{} x \IN{} <\VOID{}>[]) \{\ldots\} // \comment{OK, type of x inferred.}
@@ -24185,9 +24188,11 @@ \subsection{Definite Assignment}
2418524188
(\commentary{%
2418624189
e.g., as an expression, or as the left hand side of an assignment%
2418724190
}),
24188-
the variable has a status as being
24189-
\IndexCustom{definitely assigned}{local variable!definitely assigned} or
24190-
\IndexCustom{definitely unassigned}{local variable!definitely unassigned}.
24191+
the variable can be
24192+
\IndexCustom{definitely assigned}{local variable!definitely assigned},
24193+
and it can be
24194+
\IndexCustom{definitely unassigned}{local variable!definitely unassigned},
24195+
and it can be neither.
2419124196

2419224197
\commentary{%
2419324198
The precise flow analysis which determines this status at each location
@@ -24440,15 +24445,16 @@ \subsection{Type Promotion}
2444024445

2444124446
%% TODO(eernst), for review: The null safety spec says that `T?` is
2444224447
%% promoted to `T`, but implementations _do_ promote `X extends int?` to
24443-
%% `X & int`. So I've specified the latter. This is also more consistent
24444-
%% with the approach used with `==`.
24448+
%% `X & int`. So we may be able to specify something which will yield
24449+
%% slightly more precise types, and which is more precisely the implemented
24450+
%% behavior.
2444524451
\LMHash{}%
2444624452
A check of the form \code{$v$\,\,!=\,\,\NULL},
2444724453
\code{\NULL\,\,!=\,\,$v$},
2444824454
or \code{$v$\,\,\IS\,\,$T$}
24449-
where $v$ has type $T$ at $\ell$
24455+
where $v$ has static type $T?$ at $\ell$
2445024456
promotes the type of $v$
24451-
to \NonNullType{$T$} in the \TRUE{} continuation,
24457+
to $T$ in the \TRUE{} continuation,
2445224458
and to \code{Null} in the \FALSE{} continuation.
2445324459

2445424460
\commentary{%

0 commit comments

Comments
 (0)