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

function_default_parameter_at_end should not trigger for isolated parameter. #5793

Open
2 tasks done
Supereg opened this issue Sep 13, 2024 · 3 comments
Open
2 tasks done
Labels
enhancement Ideas for improvements of existing features and rules. good first issue Issue to be taken up by new contributors yet unfamiliar with the project.

Comments

@Supereg
Copy link

Supereg commented Sep 13, 2024

New Issue Checklist

Feature or Enhancement Proposal

Swift 6 introduced a new notation for inheriting the actor isolation from the call site (see SE-0420). The special parameter isolated is typically placed as the first argument of a method with the default value #isolation.

This violates the function_default_parameter_at_end rule and I think such cases should receive an exemption from the rule.
The current implementation, only considers closures as special cases.

// warning: Function Default Parameter at End Violation: Prefer to locate parameters with defaults toward the end of the parameter list (function_default_parameter_at_end)
func foo(isolation: isolated (any Actor)? = #isolation, bar: String) {
    print("foo \(bar)")
}

Looking at the original proposal (see SE-0313), isolated parameter can occur at any position. Checking for the isolated attribute and a default value #isolation should be enough to detect isolation inheritance.

@SimplyDanny
Copy link
Collaborator

This should be hidden behind a new option which is off by default.

@SimplyDanny SimplyDanny added enhancement Ideas for improvements of existing features and rules. good first issue Issue to be taken up by new contributors yet unfamiliar with the project. labels Sep 15, 2024
@Supereg
Copy link
Author

Supereg commented Sep 15, 2024

This should be hidden behind a new option which is off by default.

So the idea would be to add something like a ignore_isolation_inheritance_parameter configuration option for the function_default_parameter_at_end rule that is disabled by default?

@SimplyDanny
Copy link
Collaborator

This should be hidden behind a new option which is off by default.

So the idea would be to add something like a ignore_isolation_inheritance_parameter configuration option for the function_default_parameter_at_end rule that is disabled by default?

Yes, that'd be the idea. For the option name, we might prefer the plural ignore_isolation_inheritance_parameters. That's currently inconsistent throughout the configurations. Plural feels more natural though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Ideas for improvements of existing features and rules. good first issue Issue to be taken up by new contributors yet unfamiliar with the project.
Projects
None yet
Development

No branches or pull requests

2 participants