Skip to content

Commit

Permalink
Specify that a void return type doesn't cause errors in checked mode.
Browse files Browse the repository at this point in the history
R=eernst@google.com

Review-Url: https://codereview.chromium.org/2875643002 .
  • Loading branch information
lrhn committed May 11, 2017
1 parent cdfe67f commit 122345e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions docs/language/dartLangSpec.tex
Original file line number Diff line number Diff line change
Expand Up @@ -6453,8 +6453,17 @@ \subsection{ Return}
\LMHash{}
Let $S$ be the runtime type of $o$. In checked mode:
\begin{itemize}
\item If the body of $f$ is marked \ASYNC{} (\ref{functions}) it is a dynamic type error if $o$ is not \NULL{} (\ref{null}) and \code{Future<flatten(S)>} is not a subtype of the actual return type (\ref{actualTypeOfADeclaration}) of $f$.
\item Otherwise, it is a dynamic type error if $o$ is not \NULL{} and the runtime type of $o$ is not a subtype of the actual return type of $f$.
\item If the body of $f$ is marked \ASYNC{} (\ref{functions})
it is a dynamic type error if $o$ is not \NULL{} (\ref{null}),
the actual return type (\ref{actualTypeOfADeclaration}) of $f$ is not \VOID,
and \code{Future<flatten(S)>} is not a subtype of the actual return type of $f$.
% TODO(lrn): The "void foo() async { return e }" case is somewhat speculative.
% When we disallow "return e" in a void function, we might also want to revisit
% this rule. Currently it also covers the "void foo() async => e;" case, which
% we might want to allow.
\item Otherwise, it is a dynamic type error if $o$ is not \NULL{},
the actual return type of $f$ is not \VOID{},
and the runtime type of $o$ is not a subtype of the actual return type of $f$.
\end{itemize}

\LMHash{}
Expand Down

0 comments on commit 122345e

Please sign in to comment.