Skip to content

Commit 10b6ac4

Browse files
committed
Fixed the "SUB issues" section
1 parent cfa4c76 commit 10b6ac4

File tree

1 file changed

+57
-24
lines changed

1 file changed

+57
-24
lines changed

specification/dartLangSpec.tex

Lines changed: 57 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23250,7 +23250,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2325023250
\FUNCTION}.
2325123251
\item
2325223252
Let $U_1$ and $U_2$ be, respectively,
23253-
23253+
2325423254
\noindent
2325523255
\code{$T_1$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{11}$,\,\ldots,\,$X_m$\,%
2325623256
\EXTENDS\,$B_{1m}$>($P_{11}$,\,\ldots,\,$P_{1k}$)}
@@ -23283,7 +23283,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2328323283
\noindent
2328423284
\code{$T_2$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{21}$,\,\ldots,\,$X_m$\,%
2328523285
\EXTENDS\,$B_{2m}$>($P_{21}$,\,\ldots,\,$P_{2k}$,\,$\metavar{Named}_2$)}
23286-
23286+
2328723287
\noindent
2328823288
where $\metavar{Named}_j$ declares a non-empty set of named parameters
2328923289
with names $\metavar{NamesOfNamed}_j$, $j \in 1 .. 2$,
@@ -23297,7 +23297,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2329723297
\item For each required entry named $n$ in $\metavar{Named}_2$,
2329823298
$\metavar{Named}_1$ contains an entry named $n$
2329923299
(\commentary{which may or may not be required}).
23300-
\end{itemize}
23300+
\end{itemize}
2330123301

2330223302
Then \DefEqualsNewline{\UpperBoundType{$U_1$}{$U_2$}}{%
2330323303
\code{$T_3$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{31}$,\,\ldots,\,$X_m$\,%
@@ -23342,7 +23342,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2334223342
\item
2334323343
\DefEqualsNewline{\UpperBoundType{$T_1$}{$S$ \FUNCTION<\ldots>(\ldots)}}{%
2334423344
\UpperBoundType{$T_1$}{Object}}.
23345-
\item
23345+
\item
2334623346
\DefEquals{\UpperBoundType{FutureOr<$T_1$>}{FutureOr<$T_2$>}}{%
2334723347
\code{FutureOr<$T_3$>}},
2334823348
where $T_3$ = \UpperBoundType{$T_1$}{$T_2$}.
@@ -23358,7 +23358,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2335823358
\DefEquals{\UpperBoundType{$T_1$}{FutureOr<$T_2$>}}{%
2335923359
\code{FutureOr<$T_3$>}},
2336023360
where $T_3$ = \UpperBoundType{$T_1$}{$T_2$}.
23361-
\item
23361+
\item
2336223362
\DefEquals{\UpperBoundType{FutureOr<$T_1$>}{$T_2$}}{%
2336323363
\code{FutureOr<$T_3$>}},
2336423364
where $T_3$ = \UpperBoundType{$T_1$}{$T_2$}.
@@ -23505,7 +23505,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2350523505
%%
2350623506
\item
2350723507
Let $U_1$ and $U_2$ be, respectively,
23508-
23508+
2350923509
\noindent
2351023510
\code{$T_1$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{11}$,\,\ldots,\,$X_m$\,%
2351123511
\EXTENDS\,$B_{1m}$>($P_{11}$,\,\ldots,\,$P_{1k}$)}
@@ -23520,7 +23520,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2352023520
let $T_3$ be \LowerBoundType{$T_1$}{$T_2$},
2352123521
let $B_{3i}$ be $B_{1i}$, and
2352223522
let $P_{3i}$ be determined as follows:
23523-
23523+
2352423524
\begin{itemize}
2352523525
\item $P_{3i}$ is \UpperBoundType{$P_{1i}$}{$P_{2i}$} for
2352623526
$i \leq \metavar{min}(k, l)$.
@@ -23529,7 +23529,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2352923529
\item $P_{3i}$ is optional if $P_{1i}$ or $P_{2i}$ is optional,
2353023530
or if $\metavar{min}(k, l) < i \leq q$.
2353123531
\end{itemize}
23532-
23532+
2353323533
Then \DefEqualsNewline{\LowerBoundType{$U_1$}{$U_2$}}{%
2353423534
\code{$T_3$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{31}$,\,\ldots,\,$X_m$\,%
2353523535
\EXTENDS\,$B_{3m}$>($P_{31}$,\,\ldots,\,$P_{3q}$)}}.
@@ -23547,7 +23547,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2354723547
\noindent
2354823548
\code{$T_2$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{21}$,\,\ldots,\,$X_m$\,%
2354923549
\EXTENDS\,$B_{2m}$>($P_{21}$,\,\ldots,\,$P_{2k}$,\,$\metavar{Named}_2$)}
23550-
23550+
2355123551
\noindent
2355223552
where $\metavar{Named}_j$ declares a non-empty set of named parameters
2355323553
with names $\metavar{NamesOfNamed}_j$, $j \in 1 .. 2$,
@@ -23654,7 +23654,7 @@ \subsubsection{The Standard Upper Bound of Distinct Interface Types}
2365423654
\commentary{%
2365523655
For example, the algorithm yields \code{Object} as the standard upper bound of
2365623656
\code{List<Comparable<int>{}>} and \code{Iterable<int>},
23657-
but it is easy to see that a tighter upper bound exists, e.g.,
23657+
but it is easy to see that a tighter upper bound exists, e.g.,
2365823658
\code{Iterable<Comparable<num>{}>}.%
2365923659
}
2366023660

@@ -23700,18 +23700,16 @@ \subsubsection{The Standard Upper Bound of Distinct Interface Types}
2370023700
The least upper bound of $I$ and $J$ is then the sole element of $M_q$.
2370123701

2370223702

23703-
\subsubsection{Standard Upper Bound Termination}
23704-
\LMLabel{standardUpperBoundTermination}
23703+
\subsubsection{Standard Upper Bound Issues}
23704+
\LMLabel{standardUpperBoundIssues}
2370523705

23706-
%% TODO(eernst), for review: This section could be turned into a few github
23707-
%% issues, but it seems reasonable to let the user of Dart know about it.
23708-
%% So do we include it, or do we delete the whole section (and create those
23709-
%% github issues)?
23710-
%%
23711-
%% Note that I omitted the symmetry issue: The given example does not
23712-
%% demonstrate any asymmetry (both results have type `List<dynamic>`).
23713-
%% So we should study the symmetry properties a bit more if we keep this
23714-
%% section.
23706+
%% TODO(eernst), for review: I kept this here (and updated some parts of it)
23707+
%% in order to ensure that this information is preserved. However, it should
23708+
%% perhaps not be in the specification. Should it actually be turned into
23709+
%% a couple of github issues? In any case, it makes sense to communicate
23710+
%% these properties of the algoritm to anyone who needs to know the language
23711+
%% in full detail, which could justify keeping it here, or including a
23712+
%% reference to some other location where the information is available.
2371523713

2371623714
\commentary{%
2371723715
The definition of the standard upper bound for type variables
@@ -23720,9 +23718,7 @@ \subsubsection{Standard Upper Bound Termination}
2372023718
}
2372123719

2372223720
\begin{dartCode}
23723-
\VOID{} foo<T \EXTENDS{} List<S>, S \EXTENDS{} List<T>>() \{
23724-
T x;
23725-
S y;
23721+
\VOID{} foo<T \EXTENDS{} List<S>, S \EXTENDS{} List<T>>(T x, S y) \{
2372623722
\VAR{} a = (x == y) ? x : y;
2372723723
\}
2372823724
\end{dartCode}
@@ -23739,6 +23735,43 @@ \subsubsection{Standard Upper Bound Termination}
2373923735
with the current algorithm.%
2374023736
}
2374123737

23738+
\commentary{%
23739+
The current algorithm is asymmetric.
23740+
There is an equivalence class of top types,
23741+
and we correctly choose a canonical representative for bare top types
23742+
using the \IsMoreTopTypeName{} predicate.
23743+
However, when two different top types are embedded in two mutual subtypes,
23744+
we don't correctly choose a canonical representative.%
23745+
}
23746+
23747+
\begin{dartCode}
23748+
\IMPORT{} 'dart:async';
23749+
\\
23750+
\VOID{} main() \{
23751+
List<FutureOr<Object?>{}> x;
23752+
List<\DYNAMIC> y;
23753+
23754+
var a = (x == y) ? x : y; // List<\DYNAMIC>.
23755+
var b = (x == y) ? y : x; // List<FutureOr<Object?>{}>.
23756+
\}
23757+
\end{dartCode}
23758+
23759+
\commentary{%
23760+
The best solution for this is probably to normalize the types.
23761+
This is fairly straightforward:
23762+
We just normalize \code{FutureOr<$T$>} to the normal form of $T$
23763+
when $T$ is a top type.
23764+
We can then inductively apply this across the rest of the types.
23765+
Then, whenever we have mutual subtypes, we just return the normal form.
23766+
This would be breaking, albeit hopefully only in a minor way.
23767+
23768+
A similar treatment would need to be done for the bottom types as well,
23769+
since there are two equivalences there:
23770+
A type variable $X$ with bound $T$ is equivalent to \code{Never}
23771+
if $T$ is equivalent to \code{Never},
23772+
and \code{FutureOr<Never>} is equivalent to \code{Future<Never>}.%
23773+
}
23774+
2374223775

2374323776
\subsection{Least and Greatest Closure of Types}
2374423777
\LMLabel{leastAndGreatestClosureOfTypes}

0 commit comments

Comments
 (0)