swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.69k stars 10.39k forks source link

[SR-6712] Error message prints on wrong line of multi-line string literal #49261

Open swift-ci opened 6 years ago

swift-ci commented 6 years ago
Previous ID SR-6712
Radar None
Original Reporter kelan (JIRA User)
Type Bug
Environment Xcode 9.2 (9C40b), standard toolchain Apple Swift version 4.0.3 (swiftlang-900.0.74.1 clang-900.0.39.2) Target: x86_64-apple-macosx10.9
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug, Parser | |Assignee | None | |Priority | Medium | md5: 07142822c78d5469041f5dec0d0d3311

Issue Description:

REPRO
1) Make a multi-line string literal, in a statement that is missing the closing )
2) The error message is printed on the wrong line if all of the following are true:
a) There is an interpolation in the string literal (in fact, the error message is printed about the subsequent line
b) There is another, correct, statement after the incorrect statement
See example below

EXPECT
The error message should be in the line that closes the multi-line string literal (with the """)

ACTUAL
The errer message is shown on the line following the interpolation:

multiline-string-literal-error-message.swift:12:2: error: expected ',' separator
  it prints a warning about this line
  ^

EXAMPLE

let myVar = "hello"

print(
"""

  Multi line string literal

  This interpolation is important: \(myVar)
  it prints a warning about this line

  NOTE that the closing ) is missing on the next line
"""
print("and this subsequent statement is also important")
belkadan commented 6 years ago

@rintaro, have we seen this one before?