-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Allow \" in single-quoted interpolated string literals #11751
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// only the last one doesn't parse | ||
class C { | ||
s"""\ """ | ||
s"""\\""" | ||
s"""\""" | ||
s"\ " | ||
s"\\" | ||
s"\" // error | ||
} // error (should not be one) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class C { | ||
val sa = s"""\""" // error: invalid escape | ||
val sb = s"""\\""" | ||
val sc = s"""\ """ // error: invalid escape | ||
val ra = raw"""\""" | ||
val rb = raw"""\\""" | ||
val rc = raw"""\ """ | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
"Hello", Alice | ||
"Hello", Alice | ||
\"Hello\", Alice | ||
\"Hello\", Alice | ||
\"Hello\", Alice | ||
\"Hello\", Alice | ||
\TILT\ | ||
\\TILT\\ | ||
\\TILT\\ | ||
\TILT\ | ||
\\TILT\\ | ||
\\TILT\\ | ||
\TILT\ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
object Test { | ||
def main(args: Array[String]): Unit = { | ||
val person = "Alice" | ||
println(s"\"Hello\", $person") | ||
println(s"""\"Hello\", $person""") | ||
|
||
println(f"\"Hello\", $person") | ||
println(f"""\"Hello\", $person""") | ||
|
||
println(raw"\"Hello\", $person") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Questions: Now that we have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Maybe I misunderstand, but there's no special case or change in the In my opinion we should do this change change and fix scala/bug#6476, even if we have See also the (updated) PR description of scala/scala#8830 (comment).
I'm not sure what you mean by that.
Using triple-quote. The 2.13 compiler will even tell you that: scala> raw"c:\"
^
error: unclosed string literal; note that `\"` no longer closes single-quoted interpolated string literals since 2.13.6, you can use a triple-quoted string instead If desired, I can include this message in Scala 3 as well. |
||
println(raw"""\"Hello\", $person""") | ||
|
||
println(s"\\TILT\\") | ||
println(f"\\TILT\\") | ||
println(raw"\\TILT\\") | ||
|
||
println(s"""\\TILT\\""") | ||
println(f"""\\TILT\\""") | ||
println(raw"""\\TILT\\""") | ||
|
||
println(raw"""\TILT\""") | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this one was wrongly interpreted as
\"
instead of"
. The check file differs with the one in Scala 2.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I filed #11750 about that