-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Try to make returning void within dynamic an error #32161
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
Add void declarations to methods with implicit dynamic returning void values, which *may* be illegal in dart 2, but in either case, expresses the current intent better.
Add void declarations to methods with implicit dynamic returning void values, which *may* be illegal in dart 2, but in either case, expresses the current intent better.
Add void declarations to methods with implicit dynamic returning void values, which may be illegal in dart 2, but in either case, expresses the current intent better.
Add void declarations to methods with implicit dynamic returning void values, which may be illegal in dart 2, but in either case, expresses the current intent better.
Add void declarations to methods with implicit dynamic returning void values, which may be illegal in dart 2, but in either case, expresses the current intent better.
Add void declarations to methods with implicit dynamic returning void values, which may be illegal in dart 2, but in either case, expresses the current intent better.
Add void declarations to methods with implicit dynamic returning void values, which may be illegal in dart 2, but in either case, expresses the current intent better.
Add void declarations to methods with implicit dynamic returning void values, which may be illegal in dart 2, but in either case, expresses the current intent better.
Add void declarations to methods with implicit dynamic returning void values, which may be illegal in dart 2, but in either case, expresses the current intent better.
Changes for landing dart-lang/sdk#32161
Changes for landing dart-lang/sdk#32161
Changes for landing dart-lang/sdk#32161
Add void declarations to methods with implicit dynamic returning void values, which may be illegal in dart 2, but in either case, expresses the current intent better.
Add void declarations to methods with implicit dynamic returning void values, which may be illegal in dart 2, but in either case, expresses the current intent better.
Change-Id: Ifee22c00bd9384faef8ee48c1d7fd92879609ce4 Reviewed-on: https://dart-review.googlesource.com/42321 Commit-Queue: Mike Fairhurst <[email protected]> Reviewed-by: Paul Berry <[email protected]>
Change-Id: Iea314e7a23513eef1823dbfe8690494f45af9185 Reviewed-on: https://dart-review.googlesource.com/42323 Reviewed-by: Dmitry Stefantsov <[email protected]> Commit-Queue: Mike Fairhurst <[email protected]>
… function that returns dynamic. dart-lang/sdk#32161 This commonly appears in the form `f() => g()` where `g()` returns void, and `f()` is a top-level or a method, so it gets an implicit dynamic rather than type inference. Even if the restriction is not added to dart 2, this migration creates cleaner code that more often expresses the true intent. #codehealth Tested: TAP --sample for global presubmit queue http://test/OCL:186244698:BASE:186239924:1519083758984:829050d9 PiperOrigin-RevId: 186623288
Change-Id: Ic986525d61bc36fb5ad25cacb2c9233b75c38bf7 Reviewed-on: https://dart-review.googlesource.com/42322 Commit-Queue: Mike Fairhurst <[email protected]> Reviewed-by: Dmitry Stefantsov <[email protected]>
… function that returns dynamic. dart-lang/sdk#32161 This commonly appears in the form `f() => g()` where `g()` returns void, and `f()` is a top-level or a method, so it gets an implicit dynamic rather than type inference. Even if the restriction is not added to dart 2, this migration creates cleaner code that more often expresses the true intent. #codehealth Tested: TAP --sample for global presubmit queue http://test/OCL:186244698:BASE:186239924:1519083758984:829050d9 PiperOrigin-RevId: 186623288
… function that returns dynamic. dart-lang/sdk#32161 This commonly appears in the form `f() => g()` where `g()` returns void, and `f()` is a top-level or a method, so it gets an implicit dynamic rather than type inference. Even if the restriction is not added to dart 2, this migration creates cleaner code that more often expresses the true intent. #codehealth Tested: TAP --sample for global presubmit queue http://test/OCL:186244698:BASE:186239924:1519083758984:829050d9 PiperOrigin-RevId: 186623288
… function that returns dynamic. dart-lang/sdk#32161 This commonly appears in the form `f() => g()` where `g()` returns void, and `f()` is a top-level or a method, so it gets an implicit dynamic rather than type inference. Even if the restriction is not added to dart 2, this migration creates cleaner code that more often expresses the true intent. #codehealth Tested: TAP --sample for global presubmit queue http://test/OCL:186244698:BASE:186239924:1519083758984:829050d9 PiperOrigin-RevId: 186623288
… function that returns dynamic. dart-lang/sdk#32161 This commonly appears in the form `f() => g()` where `g()` returns void, and `f()` is a top-level or a method, so it gets an implicit dynamic rather than type inference. Even if the restriction is not added to dart 2, this migration creates cleaner code that more often expresses the true intent. #codehealth Tested: TAP --sample for global presubmit queue http://test/OCL:186244698:BASE:186239924:1519083758984:829050d9 PiperOrigin-RevId: 186623288
… function that returns dynamic. dart-lang/sdk#32161 This commonly appears in the form `f() => g()` where `g()` returns void, and `f()` is a top-level or a method, so it gets an implicit dynamic rather than type inference. Even if the restriction is not added to dart 2, this migration creates cleaner code that more often expresses the true intent. #codehealth Tested: TAP --sample for global presubmit queue http://test/OCL:186244698:BASE:186239924:1519083758984:829050d9 PiperOrigin-RevId: 186623288
Add voids to support dart-lang/sdk#32161
Changes for landing dart-lang/sdk#32161
@MichaelRFairhurst How is work on this issue going? |
fixes are all landed, but @leafpetersen decided it might not be best for Dart to land this in the analyzer. @leafpetersen is that decided for sure yet? Can we close this? |
The language team has agreed to make one change that would be quite important for this issue: An void foo() => 42; // Sugar for `void foo() { 42; }`.
foo() => print('Hello!'); // Sugar for `void foo() { print('Hello!'); }`. I suspect that this decision is sitting in the pipeline (so you might not have had a chance to hear about it yet, and it isn't in any feature spec), but it should change the situation around a substantial number of functions which are "void with =>". The remaining ones (stuff like I believe that almost all the other fixes (presumably they would be "add an explicit Of course, the semantics of the targeted |
Is this for top levels or just local closures? |
Obviously, we need to specify this, like right now. However, let me try to give an estimated answer. ;-) In all cases, it's about The discussion was specifically about top-level functions, so the rule would apply for them. For static functions, we might want to consider class members together, in order to keep the number of rules/exceptions low. In isolation, it seems likely that static functions should be able to use this rule, just like top-level functions. For instance methods there is a clash between omitting parts of the method signature and getting them implicitly from a supertype, and applying this rule when the return type is omitted. So considering For local functions there is no ambiguity: They already get an inferred return type if the return type is omitted. The reason why this is possible is that they have no dependency cycles, so the complexity cannot explode. Function literals have inference, too. So we need to carefully consider the locations where this rule is applied, starting with the safe bet which is the top level. |
Closing, we can have a new ticket made once the change is specced, and that may be after the front end/analyzer integration anyways. Sound good @eernstg ? |
Sounds good @MichaelRFairhurst, thanks! Specification work is handled via #33069. |
Add void declarations to methods with implicit dynamic returning void values, which may be illegal in dart 2, but in either case, expresses the current intent better.
Add void declarations to methods with implicit dynamic returning void values, which may be illegal in dart 2, but in either case, expresses the current intent better.
Add void declarations to methods with implicit dynamic returning void values, which may be illegal in dart 2, but in either case, expresses the current intent better.
…id-fixes Changes for landing dart-lang/sdk#32161
Work to do:
Split out from #30177
The text was updated successfully, but these errors were encountered: