Skip to content

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

Open
@modulovalue

Description

@modulovalue

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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4area-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-assistIssues with analysis server assistsdevexp-serverIssues related to some aspect of the analysis servertype-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions