Skip to content
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

Analyzer gives wrong error for sync* that returns #43665

Closed
Hixie opened this issue Oct 4, 2020 · 0 comments
Closed

Analyzer gives wrong error for sync* that returns #43665

Hixie opened this issue Oct 4, 2020 · 0 comments
Assignees
Labels
analyzer-ux area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request

Comments

@Hixie
Copy link
Contributor

Hixie commented Oct 4, 2020

Iterable<int> get foo sync* => ['a'].map<int>(int.parse);

void main() {
  print(foo);
}

Analyzer (incorrect):

  error • Functions marked 'async' must have a return type assignable to 'Future' • test.dart:1:1 • illegal_async_return_type
  error • Can't return a value from a generator function (using the 'async*' modifier) • test.dart:1:29 • return_in_generator

Compiler (correct):

test.dart:1:32: Error: 'sync*' and 'async*' can't return a value.
Iterable<int> get foo sync* => ['a'].map<int>(int.parse);
                               ^
@mit-mit mit-mit added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label Oct 5, 2020
@srawlins srawlins added analyzer-ux P3 A lower priority bug or feature request labels Nov 25, 2020
@srawlins srawlins self-assigned this Aug 22, 2021
dart-bot pushed a commit that referenced this issue Aug 24, 2021
* This message should only be reported by the parser; the
  error raised in the analyzer was strictly duplicate.
* This message theoretically used to mention "async*" or
  "sync*" depending on the modifier that the function in
  question listed. However, listing one modifier or the
  other is a red herring, and may confuse the user; any
  function declared with one or the other is a "generator",
  and the error applies equally to a "generator" using one
  or the other modifier.

Bug: #43665
Change-Id: I6ef1f5c055473170e7563222f6f0a6c56a4ad5f5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210801
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-ux area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request
Projects
None yet
Development

No branches or pull requests

3 participants