Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: docs/language/dartLangSpec.tex

Issue 2875643002: Specify that a void return type doesn't cause errors in checked mode. (Closed)
Patch Set: Add comment Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 \documentclass{article} 1 \documentclass{article}
2 \usepackage{epsfig} 2 \usepackage{epsfig}
3 \usepackage{color} 3 \usepackage{color}
4 \usepackage{dart} 4 \usepackage{dart}
5 \usepackage{bnf} 5 \usepackage{bnf}
6 \usepackage{hyperref} 6 \usepackage{hyperref}
7 \usepackage{lmodern} 7 \usepackage{lmodern}
8 \usepackage[T1]{fontenc} 8 \usepackage[T1]{fontenc}
9 \newcommand{\code}[1]{{\sf #1}} 9 \newcommand{\code}[1]{{\sf #1}}
10 \title{Dart Programming Language Specification \\ 10 \title{Dart Programming Language Specification \\
(...skipping 6435 matching lines...) Expand 10 before | Expand all | Expand 10 after
6446 6446
6447 \LMHash{} 6447 \LMHash{}
6448 Let $T$ be the static type of $e$ and let $f$ be the immediately enclosing funct ion. 6448 Let $T$ be the static type of $e$ and let $f$ be the immediately enclosing funct ion.
6449 6449
6450 \LMHash{} 6450 \LMHash{}
6451 It is a static type warning if the body of $f$ is marked \ASYNC{} and the type \ code{Future<flatten(T)>} (\ref{functionExpressions}) may not be assigned to the declared return type of $f$. Otherwise, it is a static type warning if $T$ ma y not be assigned to the declared return type of $f$. 6451 It is a static type warning if the body of $f$ is marked \ASYNC{} and the type \ code{Future<flatten(T)>} (\ref{functionExpressions}) may not be assigned to the declared return type of $f$. Otherwise, it is a static type warning if $T$ ma y not be assigned to the declared return type of $f$.
6452 6452
6453 \LMHash{} 6453 \LMHash{}
6454 Let $S$ be the runtime type of $o$. In checked mode: 6454 Let $S$ be the runtime type of $o$. In checked mode:
6455 \begin{itemize} 6455 \begin{itemize}
6456 \item If the body of $f$ is marked \ASYNC{} (\ref{functions}) it is a dynamic t ype error if $o$ is not \NULL{} (\ref{null}) and \code{Future<flatten(S)>} is no t a subtype of the actual return type (\ref{actualTypeOfADeclaration}) of $f$. 6456 \item If the body of $f$ is marked \ASYNC{} (\ref{functions})
6457 \item Otherwise, it is a dynamic type error if $o$ is not \NULL{} and the runtim e type of $o$ is not a subtype of the actual return type of $f$. 6457 it is a dynamic type error if $o$ is not \NULL{} (\ref{null}),
6458 the actual return type (\ref{actualTypeOfADeclaration}) of $f$ is not \VOID,
6459 and \code{Future<flatten(S)>} is not a subtype of the actual return type of $f$.
6460 % TODO(lrn): The "void foo() async { return e }" case is somewhat speculative.
6461 % When we disallow "return e" in a void function, we might also want to revisit
6462 % this rule. Currently it also covers the "void foo() async => e;" case, which
6463 % we might want to allow.
6464 \item Otherwise, it is a dynamic type error if $o$ is not \NULL{},
6465 the actual return type of $f$ is not \VOID{},
6466 and the runtime type of $o$ is not a subtype of the actual return type of $f$.
6458 \end{itemize} 6467 \end{itemize}
6459 6468
6460 \LMHash{} 6469 \LMHash{}
6461 It is a compile-time error if a return statement of the form \code{\RETURN{} $e$ ;} appears in a generative constructor (\ref{generativeConstructors}). 6470 It is a compile-time error if a return statement of the form \code{\RETURN{} $e$ ;} appears in a generative constructor (\ref{generativeConstructors}).
6462 6471
6463 \rationale{ 6472 \rationale{
6464 It is quite easy to forget to add the factory prefix for a constructor, accident ally converting a factory into a generative constructor. The static checker may detect a type mismatch in some, but not all, of these cases. The rule above help s catch such errors, which can otherwise be very hard to recognize. There is no real downside to it, as returning a value from a generative constructor is meani ngless. 6473 It is quite easy to forget to add the factory prefix for a constructor, accident ally converting a factory into a generative constructor. The static checker may detect a type mismatch in some, but not all, of these cases. The rule above help s catch such errors, which can otherwise be very hard to recognize. There is no real downside to it, as returning a value from a generative constructor is meani ngless.
6465 } 6474 }
6466 6475
6467 \LMHash{} 6476 \LMHash{}
(...skipping 1681 matching lines...) Expand 10 before | Expand all | Expand 10 after
8149 8158
8150 The invariant that each normative paragraph is associated with a line 8159 The invariant that each normative paragraph is associated with a line
8151 containing the text \LMHash{} should be maintained. Extra occurrences 8160 containing the text \LMHash{} should be maintained. Extra occurrences
8152 of \LMHash{} can be added if needed, e.g., in order to make 8161 of \LMHash{} can be added if needed, e.g., in order to make
8153 individual \item{}s in itemized lists addressable. Each \LM.. command 8162 individual \item{}s in itemized lists addressable. Each \LM.. command
8154 must occur on a separate line. \LMHash{} must occur immediately 8163 must occur on a separate line. \LMHash{} must occur immediately
8155 before the associated paragraph, and \LMLabel must occur immediately 8164 before the associated paragraph, and \LMLabel must occur immediately
8156 after the associated \section{}, \subsection{} etc. 8165 after the associated \section{}, \subsection{} etc.
8157 8166
8158 ---------------------------------------------------------------------- 8167 ----------------------------------------------------------------------
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698