Skip to content

Running formatter produces invalid Swift #1107

Closed
@ahoppen

Description

@ahoppen

Formatting this code

_ = [
  Node(
    documentation: """
    A single argument that can be added to a lifetime specifier like `borrow`, `mutate`, `consume` or `copy`.

    ### Example
    `data` in `func foo(data: Array<Item>) -> borrow(data) ComplexReferenceType`
    """,
    children: [
      Child(
        documentation: """
        The parameter on which the lifetime of this type depends. 
        
        This can be an identifier referring to an external parameter name, an integer literal to refer to an unnamed
        parameter or `self` if the type's lifetime depends on the object the method is called on.
        """
      ),
    ]
  )
]

produces

_ = [
  Node(
    documentation: """
      A single argument that can be added to a lifetime specifier like `borrow`, `mutate`, `consume` or `copy`.

      ### Example
      `data` in `func foo(data: Array<Item>) -> borrow(data) ComplexReferenceType`
      """,
    children: [
      Child(
        documentation: """
          The parameter on which the lifetime of this type depends. 
 
         This can be an identifier referring to an external parameter name, an integer literal to refer to an unnamed
          parameter or `self` if the type's lifetime depends on the object the method is called on.
          """
      )
    ]
  )
]

Which is invalid because This can be has insufficient indentation. Instead, the previous line has a single space when it shouldn’t have any.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions