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

[SR-13722] Fixit for misplaced parameter attributes #56119

Open
groue opened this issue Oct 11, 2020 · 1 comment
Open

[SR-13722] Fixit for misplaced parameter attributes #56119

groue opened this issue Oct 11, 2020 · 1 comment

Comments

@groue
Copy link

groue commented Oct 11, 2020

Previous ID SR-13722
Radar rdar://problem/70298069
Original Reporter @groue
Type Improvement
Additional Detail from JIRA
Votes 0
Component/s
Labels Improvement
Assignee None
Priority Medium

md5: a4d57a86c8b2138eca5ba8768697dda6

Issue Description:

When a user uses a parameter attribute as a type attribute, the compiler outputs an "unknown attribute" error message which does not help the user understand and fix the error:

error: unknown attribute 'ViewBuilder'
func footer<Footer: View>(_ footer: @ViewBuilder () -> Footer) -> some View {
                                     ^

Can we improve the error message, and is provide a fixit?

error: attribute can only be applied to parameters, not types
func footer<Footer: View>(_ footer: @ViewBuilder () -> Footer) -> some View { ... }
                                    ~^~~~~~~~~~~~
                          @ViewBuilder

For more context, please see this message by the Core Team member Doug Gregor: https://forums.swift.org/t/se-0289-review-2-result-builders/40585/134

@typesanitizer
Copy link

There's a pitch going on which would make this construct legal.

https://forums.swift.org/t/pitch-2-extend-property-wrappers-to-function-and-closure-parameters/40959

I'm not sure if it's worth fixing the diagnostic only to have it removed soon, but we should double-check that this does get fixed if the corresponding proposal is implemented+approved.

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants