Skip to content

Commit 5ca904a

Browse files
committed
Fixed the "SUB issues" section
1 parent c9e86ae commit 5ca904a

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
@@ -23606,7 +23606,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2360623606
\FUNCTION}.
2360723607
\item
2360823608
Let $U_1$ and $U_2$ be, respectively,
23609-
23609+
2361023610
\noindent
2361123611
\code{$T_1$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{11}$,\,\ldots,\,$X_m$\,%
2361223612
\EXTENDS\,$B_{1m}$>($P_{11}$,\,\ldots,\,$P_{1k}$)}
@@ -23639,7 +23639,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2363923639
\noindent
2364023640
\code{$T_2$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{21}$,\,\ldots,\,$X_m$\,%
2364123641
\EXTENDS\,$B_{2m}$>($P_{21}$,\,\ldots,\,$P_{2k}$,\,$\metavar{Named}_2$)}
23642-
23642+
2364323643
\noindent
2364423644
where $\metavar{Named}_j$ declares a non-empty set of named parameters
2364523645
with names $\metavar{NamesOfNamed}_j$, $j \in 1 .. 2$,
@@ -23653,7 +23653,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2365323653
\item For each required entry named $n$ in $\metavar{Named}_2$,
2365423654
$\metavar{Named}_1$ contains an entry named $n$
2365523655
(\commentary{which may or may not be required}).
23656-
\end{itemize}
23656+
\end{itemize}
2365723657

2365823658
Then \DefEqualsNewline{\UpperBoundType{$U_1$}{$U_2$}}{%
2365923659
\code{$T_3$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{31}$,\,\ldots,\,$X_m$\,%
@@ -23698,7 +23698,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2369823698
\item
2369923699
\DefEqualsNewline{\UpperBoundType{$T_1$}{$S$ \FUNCTION<\ldots>(\ldots)}}{%
2370023700
\UpperBoundType{$T_1$}{Object}}.
23701-
\item
23701+
\item
2370223702
\DefEquals{\UpperBoundType{FutureOr<$T_1$>}{FutureOr<$T_2$>}}{%
2370323703
\code{FutureOr<$T_3$>}},
2370423704
where $T_3$ = \UpperBoundType{$T_1$}{$T_2$}.
@@ -23714,7 +23714,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2371423714
\DefEquals{\UpperBoundType{$T_1$}{FutureOr<$T_2$>}}{%
2371523715
\code{FutureOr<$T_3$>}},
2371623716
where $T_3$ = \UpperBoundType{$T_1$}{$T_2$}.
23717-
\item
23717+
\item
2371823718
\DefEquals{\UpperBoundType{FutureOr<$T_1$>}{$T_2$}}{%
2371923719
\code{FutureOr<$T_3$>}},
2372023720
where $T_3$ = \UpperBoundType{$T_1$}{$T_2$}.
@@ -23861,7 +23861,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2386123861
%%
2386223862
\item
2386323863
Let $U_1$ and $U_2$ be, respectively,
23864-
23864+
2386523865
\noindent
2386623866
\code{$T_1$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{11}$,\,\ldots,\,$X_m$\,%
2386723867
\EXTENDS\,$B_{1m}$>($P_{11}$,\,\ldots,\,$P_{1k}$)}
@@ -23876,7 +23876,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2387623876
let $T_3$ be \LowerBoundType{$T_1$}{$T_2$},
2387723877
let $B_{3i}$ be $B_{1i}$, and
2387823878
let $P_{3i}$ be determined as follows:
23879-
23879+
2388023880
\begin{itemize}
2388123881
\item $P_{3i}$ is \UpperBoundType{$P_{1i}$}{$P_{2i}$} for
2388223882
$i \leq \metavar{min}(k, l)$.
@@ -23885,7 +23885,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2388523885
\item $P_{3i}$ is optional if $P_{1i}$ or $P_{2i}$ is optional,
2388623886
or if $\metavar{min}(k, l) < i \leq q$.
2388723887
\end{itemize}
23888-
23888+
2388923889
Then \DefEqualsNewline{\LowerBoundType{$U_1$}{$U_2$}}{%
2389023890
\code{$T_3$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{31}$,\,\ldots,\,$X_m$\,%
2389123891
\EXTENDS\,$B_{3m}$>($P_{31}$,\,\ldots,\,$P_{3q}$)}}.
@@ -23903,7 +23903,7 @@ \subsubsection{Standard Upper Bounds and Standard Lower Bounds}
2390323903
\noindent
2390423904
\code{$T_2$\,\FUNCTION<$X_1$\,\EXTENDS\,$B_{21}$,\,\ldots,\,$X_m$\,%
2390523905
\EXTENDS\,$B_{2m}$>($P_{21}$,\,\ldots,\,$P_{2k}$,\,$\metavar{Named}_2$)}
23906-
23906+
2390723907
\noindent
2390823908
where $\metavar{Named}_j$ declares a non-empty set of named parameters
2390923909
with names $\metavar{NamesOfNamed}_j$, $j \in 1 .. 2$,
@@ -24010,7 +24010,7 @@ \subsubsection{The Standard Upper Bound of Distinct Interface Types}
2401024010
\commentary{%
2401124011
For example, the algorithm yields \code{Object} as the standard upper bound of
2401224012
\code{List<Comparable<int>{}>} and \code{Iterable<int>},
24013-
but it is easy to see that a tighter upper bound exists, e.g.,
24013+
but it is easy to see that a tighter upper bound exists, e.g.,
2401424014
\code{Iterable<Comparable<num>{}>}.%
2401524015
}
2401624016

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

2405824058

24059-
\subsubsection{Standard Upper Bound Termination}
24060-
\LMLabel{standardUpperBoundTermination}
24059+
\subsubsection{Standard Upper Bound Issues}
24060+
\LMLabel{standardUpperBoundIssues}
2406124061

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

2407224070
\commentary{%
2407324071
The definition of the standard upper bound for type variables
@@ -24076,9 +24074,7 @@ \subsubsection{Standard Upper Bound Termination}
2407624074
}
2407724075

2407824076
\begin{dartCode}
24079-
\VOID{} foo<T \EXTENDS{} List<S>, S \EXTENDS{} List<T>>() \{
24080-
T x;
24081-
S y;
24077+
\VOID{} foo<T \EXTENDS{} List<S>, S \EXTENDS{} List<T>>(T x, S y) \{
2408224078
\VAR{} a = (x == y) ? x : y;
2408324079
\}
2408424080
\end{dartCode}
@@ -24095,6 +24091,43 @@ \subsubsection{Standard Upper Bound Termination}
2409524091
with the current algorithm.%
2409624092
}
2409724093

24094+
\commentary{%
24095+
The current algorithm is asymmetric.
24096+
There is an equivalence class of top types,
24097+
and we correctly choose a canonical representative for bare top types
24098+
using the \IsMoreTopTypeName{} predicate.
24099+
However, when two different top types are embedded in two mutual subtypes,
24100+
we don't correctly choose a canonical representative.%
24101+
}
24102+
24103+
\begin{dartCode}
24104+
\IMPORT{} 'dart:async';
24105+
\\
24106+
\VOID{} main() \{
24107+
List<FutureOr<Object?>{}> x;
24108+
List<\DYNAMIC> y;
24109+
24110+
var a = (x == y) ? x : y; // List<\DYNAMIC>.
24111+
var b = (x == y) ? y : x; // List<FutureOr<Object?>{}>.
24112+
\}
24113+
\end{dartCode}
24114+
24115+
\commentary{%
24116+
The best solution for this is probably to normalize the types.
24117+
This is fairly straightforward:
24118+
We just normalize \code{FutureOr<$T$>} to the normal form of $T$
24119+
when $T$ is a top type.
24120+
We can then inductively apply this across the rest of the types.
24121+
Then, whenever we have mutual subtypes, we just return the normal form.
24122+
This would be breaking, albeit hopefully only in a minor way.
24123+
24124+
A similar treatment would need to be done for the bottom types as well,
24125+
since there are two equivalences there:
24126+
A type variable $X$ with bound $T$ is equivalent to \code{Never}
24127+
if $T$ is equivalent to \code{Never},
24128+
and \code{FutureOr<Never>} is equivalent to \code{Future<Never>}.%
24129+
}
24130+
2409824131

2409924132
\subsection{Least and Greatest Closure of Types}
2410024133
\LMLabel{leastAndGreatestClosureOfTypes}

0 commit comments

Comments
 (0)