Added return-void-2-dynamic to whitelist of generalized-void.md
We need to clarify the following case:
`dynamic foo() => print('');`,
`dynamic bar() { return print(''); }`
that is, using `return e` where `e` has type `void`, when the return
type of the enclosing function is `dynamic` (inferred or explicit).
We do not currently have any elements in the generalized-void.md
whitelist for that, so it's an error. However, invalid_returns.md
from https://dart-review.googlesource.com/c/sdk/+/60401 implies
(patchset 6: line 19-20 and 34-35) that it is allowed.
It is my impression that we agree on invalid_returns.md, and also
that it describes the current behavior (maybe not 100%?).
This indicates to me that we should, probably, add an element to
the above-mentioned whitelist to allow it.
This CL makes that change to generalized-void.md.
Change-Id: I0326081960deda907b3b4ff34bd2d60f7c9dc35b
Reviewed-on: https://dart-review.googlesource.com/64341
Reviewed-by: Erik Ernst <eernst@google.com>
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
**Author**: eernst@
|
||||
|
||||
**Version**: 0.9 (2018-02-22)
|
||||
**Version**: 0.10 (2018-07-10)
|
||||
|
||||
**Status**: Under implementation.
|
||||
|
||||
@@ -282,7 +282,9 @@ for the following situations:
|
||||
no additional tokens are included, it is only the non-terminal which
|
||||
changes.*
|
||||
* In a return statement `return e;`, when the return type of the innermost
|
||||
enclosing function is the type void, `e` may have type void.
|
||||
enclosing function is the type void or dynamic, `e` may have type void.
|
||||
* In an arrow function body `=> e`, when the return type is the type void
|
||||
or dynamic, the returned expression `e` may have type void.
|
||||
* An initializing expression for a variable of type void may have the type
|
||||
void.
|
||||
* An actual parameter expression corresponding to a formal parameter whose
|
||||
@@ -389,6 +391,10 @@ bound as `Object`.
|
||||
|
||||
## Updates
|
||||
|
||||
* July 10th 2018, v0.10: Added case to whitelist: It is not an error
|
||||
to `return e;` with an `e` of type `void` when the return type is
|
||||
`dynamic`.
|
||||
|
||||
* February 22nd 2018, v0.9: Added several new contexts where an
|
||||
expression with static type void may be evaluated, such that pure data
|
||||
transfers to a target of type void are allowed. For instance, a void
|
||||
|
||||
Reference in New Issue
Block a user