Skip to content

[analyzer] Convert to expression body refactoring with IIFE produces invalid programs. #51421

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

Open
modulovalue opened this issue Feb 15, 2023 · 6 comments
Labels
area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. devexp-assist Issues with analysis server assists devexp-server Issues related to some aspect of the analysis server P4 type-enhancement A request for a change that isn't a bug

Comments

@modulovalue
Copy link
Contributor

Consider the following:

void main() {
  final a = () {
    return 0;
  }();
}

If we use the 'Convert to expression body' refactoring to convert the body of the function literal into an expression body, we will end up with an invalid program:

void main() {
  final a = () => 0();
}

I think that we should probably remove the function invocation and the surrounding function expression if this refactoring is invoked on an IIFE containing a single return statement:

void main() {
  final a = 0;
}
@asashour
Copy link
Contributor

@mraleph mraleph added the legacy-area-analyzer Use area-devexp instead. label Feb 16, 2023
@scheglov scheglov added devexp-server Issues related to some aspect of the analysis server P4 devexp-assist Issues with analysis server assists labels Feb 17, 2023
@modulovalue
Copy link
Contributor Author

@asashour I'm wondering what happened to https://dart-review.googlesource.com/c/sdk/+/283360 it looks like it is done but was not merged?

@asashour
Copy link
Contributor

asashour commented Mar 9, 2023

I am under the impression that the team is busy for other issues, needed for the beta release. Kind reminders would be send after it is shipped.

@bwilkerson
Copy link
Member

That is correct. We don't currently have many cycles available for work that isn't directly related to Dart 3.0

@modulovalue
Copy link
Contributor Author

I see, that makes sense to me. Thank you for the explanation!

@srawlins srawlins added the type-enhancement A request for a change that isn't a bug label Mar 15, 2024
@FMorschel
Copy link
Contributor

@asashour maybe rebasing it now would make it possible for them to merge? WDYT?

@bwilkerson bwilkerson added area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. and removed legacy-area-analyzer Use area-devexp instead. labels Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. devexp-assist Issues with analysis server assists devexp-server Issues related to some aspect of the analysis server P4 type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

7 participants