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

unusedArguments does not work with functions calling functions with the same labels #1902

Open
reika727 opened this issue Oct 6, 2024 · 0 comments
Labels

Comments

@reika727
Copy link

reika727 commented Oct 6, 2024

I have a code like this:

func f(foo _: Int) {}

func g(foo: Int) {
    f(foo: 42)
}

This code does not change after being formatted. However, the argument foo is not used inside the function g, so it should be func g(foo _: Int) (since the unusedArguments option is enabled by default.)

If you comment out the call of f inside g, the code will be formatted properly.

// BEFORE FORMATTED
func f(foo _: Int) {}

func g(foo: Int) {
    // f(foo: 42)
}
// AFTER FORMATTED
func f(foo _: Int) {}

func g(foo _: Int) {
    // f(foo: 42)
}

So maybe this strange behavior comes from f and g having the same argument label foo?

Environment

$ swiftformat --version
0.54.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants