Skip to content

No Fix-It for @main struct without main static function #58518

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
ahoppen opened this issue Apr 29, 2022 · 0 comments · May be fixed by #81807
Open

No Fix-It for @main struct without main static function #58518

ahoppen opened this issue Apr 29, 2022 · 0 comments · May be fixed by #81807
Assignees
Labels
compiler The Swift compiler itself diagnostics QoI Bug: Diagnostics Quality of Implementation fix-its Feature: diagnostic fix-its improvement type checker Area → compiler: Semantic analysis

Comments

@ahoppen
Copy link
Member

ahoppen commented Apr 29, 2022

When compiling the following code, you get an error message: 'Foo' is annotated with @main and must provide a main static function of type () -> Void, () throws -> Void, () async -> Void, or () async throws -> Void

@main struct Foo {
}

We should offer a fix-it to add

static func main() {
  <#code#>
}

I’m open to whether we should also suggest the async and throws variations but IMHO just offering the base variation without any modifiers would be a good starting point.

rdar://92511524

@etcwilde etcwilde self-assigned this Apr 29, 2022
@AnthonyLatsis AnthonyLatsis added compiler The Swift compiler itself diagnostics QoI Bug: Diagnostics Quality of Implementation type checker Area → compiler: Semantic analysis fix-its Feature: diagnostic fix-its labels Nov 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler The Swift compiler itself diagnostics QoI Bug: Diagnostics Quality of Implementation fix-its Feature: diagnostic fix-its improvement type checker Area → compiler: Semantic analysis
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants