-
Notifications
You must be signed in to change notification settings - Fork 1.7k
NNBD: Dart does not throw a compile error when async function with Future<bool> return type returns dynamic. #41437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@eernstg @leafpetersen - can you please sanity check intended behavior and reassign to analyzer if needed? Not clear to me if there should be an implicit cast and no static error above. |
The analyzer behavior is correct per the current specification. @eernstg is taking a pass over the specification of returns and will follow up with action items as appropriate. |
@leafpetersen @eernstg Where is this specified ? So is it ok to have method(dynamic o) {
bool b = o; // implicit cast
} but not ok to have bool method(dynamic o) {
return o; // no implicit cast ?
} ? |
Reading analyzer error again I think I got it. The problem is assigning |
I already reported the analyzer error message in #41266 (comment), but that issue was closed because the discussions about The PR where new rules about The new (null-safety specific) rules, if adopted, will make it an error to Example: |
https://dart.dev/guides/language/specifications/DartLangSpec-v2.2.pdf , section 17.12 has the current specified rules (adapted appropriately when running with null safety to account for the different assignability). @eernstg is proposing changes to this for null safety, if those changes are accepted we will land them as a change to the null safety feature specification, land tests, and file implementation issues. |
Dart VM version: 2.8.0-dev.18.0 (dev) (Fri Mar 27 11:10:52 2020 +0100) on "windows_x64"
The following sample code example throws a compile error with analyzer on the line 3 and passes without any error with dart:
Seems like dart should throw a compile error here too. Please see discussion in the Issue #41266 for more details.
Sample output is:
The text was updated successfully, but these errors were encountered: