Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SI-5856 enables use of $this in string interpolation
This pull request fixes SI-5856. The scanner has been modified to return the correct token if keywords appear in $-expressions. The parser has been modified to issue an error and to only accept $<identifier>, $this and $block.
- Loading branch information
Showing
5 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
t5856.scala:10: error: invalid string interpolation: $$, $ident or $block expected | ||
val s9 = s"$" | ||
^ | ||
t5856.scala:10: error: unclosed string literal | ||
val s9 = s"$" | ||
^ | ||
t5856.scala:2: error: error in interpolated string: identifier or block expected | ||
val s1 = s"$null" | ||
^ | ||
t5856.scala:3: error: error in interpolated string: identifier or block expected | ||
val s2 = s"$false" | ||
^ | ||
t5856.scala:4: error: error in interpolated string: identifier or block expected | ||
val s3 = s"$true" | ||
^ | ||
t5856.scala:5: error: error in interpolated string: identifier or block expected | ||
val s4 = s"$yield" | ||
^ | ||
t5856.scala:6: error: error in interpolated string: identifier or block expected | ||
val s5 = s"$return" | ||
^ | ||
t5856.scala:7: error: error in interpolated string: identifier or block expected | ||
val s6 = s"$new" | ||
^ | ||
t5856.scala:8: error: error in interpolated string: identifier or block expected | ||
val s7 = s"$s1 $null $super" | ||
^ | ||
t5856.scala:9: error: error in interpolated string: identifier or block expected | ||
val s8 = s"$super" | ||
^ | ||
10 errors found |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
object Test { | ||
val s1 = s"$null" | ||
val s2 = s"$false" | ||
val s3 = s"$true" | ||
val s4 = s"$yield" | ||
val s5 = s"$return" | ||
val s6 = s"$new" | ||
val s7 = s"$s1 $null $super" | ||
val s8 = s"$super" | ||
val s9 = s"$" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
object Test extends App { | ||
override def toString = "Test" | ||
|
||
assert(s"$this" == "Test") | ||
assert(s"$this$this" == "TestTest") | ||
assert(s"$this$$" == "Test$") | ||
assert(s"$this.##" == "Test.##") | ||
assert(s"$this.toString" == "Test.toString") | ||
assert(s"$this=THIS" == "Test=THIS") | ||
} |