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-14853] prioritizeKeepingFunctionOutputTogether always splits init parameters #307

Closed
klanchman opened this issue Jun 29, 2021 · 2 comments
Labels
bug Something isn't working swift-format

Comments

@klanchman
Copy link

Previous ID SR-14853
Radar None
Original Reporter @klanchman
Type Bug
Environment
  • macOS 11.4 (20F71)

  • swift-format 0.50400.0, release configuration

Additional Detail from JIRA
Votes 0
Component/s swift-format
Labels Bug
Assignee None
Priority Medium

md5: c5349ac25845be9c05ee8df8efcf94cd

Issue Description:

When using prioritizeKeepingFunctionOutputTogether in release configuration, any init with a parameter is split onto multiple lines, even if it fits within the max line length without line breaks.

Example:

Given this file:

struct Foo {
    init() {
        print("This one is fine")
    }

    init(a: String) {
        print("This one is not")
    }

    init(a: String, b: String) {
        print("This one is not")
    }

    func foo(a: String) {
        print("This one is fine")
    }
}

When using prioritizeKeepingFunctionOutputTogether, formatting results in the following output:

struct Foo {
    init() {
        print("This one is fine")
    }

    init(
        a: String
    ) {
        print("This one is not")
    }

    init(
        a: String, b: String
    ) {
        print("This one is not")
    }

    func foo(a: String) {
        print("This one is fine")
    }
}

Note that this only occurs with init, not regular func, as the example shows.

This is potentially related to SR-13049. When I try the above with a debug configuration, swift-format crashes with SwiftFormatPrettyPrint/PrettyPrint.swift:675: Assertion failed: Too many unresolved delmiter token lengths.

@typesanitizer
Copy link

cc @allevato

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 9, 2022
@klanchman
Copy link
Author

It looks like this was fixed in v508 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working swift-format
Projects
None yet
Development

No branches or pull requests

2 participants