Skip to content

Interpolation wrapping breaks multi-line string indentation #1226

Description

@dduan

A wrapped line inside a \(…) interpolation is not re-indented to the
multi-line string's indentation, so it ends up less-indented than the closing
""", producing source that no longer compiles.

Input

func test() {
  view {
    Button("Hi") {}
      .label(
        """
\(name: Color(
    .sRGBLinear, red: 1.0, green: 0.6, blue: 0.0))
""")
      .id("button")
  }
}

Output (invalid)

    Button("Hi") {}.label(
      """
      \(name: Color(
    .sRGBLinear, red: 1.0, green: 0.6, blue: 0.0))
      """
    ).id("button")

error: insufficient indentation of line in multi-line string literal — the
.sRGBLinear line (col 4) is less indented than the closing """ (col 6).

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