swiftlang/swift-syntax

Improperly escaped backslash in fix-it message

AppAppWorks opened this issue · 1 comments

Issue Kind

Bad Diagnostic Produced

Source Code

"""
foo \
"""

Description

The following fix-it message contains an improperly escaped backslash.

extension FixItMessage where Self == StaticParserFixIt {
  ...
  public static var removeBackslash: Self {
    .init("remove '\'")
  }
  ...
}

This results in bad diagnostic produced, e.g.

func testMultilineErrors24() {
  assertParseWithAllNewlineEndings(
    #"""
    _ = """
      foo1️⃣\
      """
    """#,
    diagnostics: [
      DiagnosticSpec(
        message: "escaped newline at the last line of a multi-line string literal is not allowed",
        fixIts: ["remove ''"]
      )
    ],
    fixedSource: #"""
      _ = """
        foo
        """
      """#
  )
}

Synced to Apple’s issue tracker as rdar://132054843