diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-08-16 11:16:36 -0700 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-08-16 11:16:36 -0700 |
commit | 560b3728f364f3523a2bad202d41881f719b9fad (patch) | |
tree | 1edb8ee3456f7fe897e5cc5004360d5cb9adc982 | |
parent | 83e95c0fa5168e64299d85b081b21c577ce4e8ef (diff) | |
parent | 9d5c97cb0155c0a2d375be6904eef8f882970615 (diff) | |
download | scala-560b3728f364f3523a2bad202d41881f719b9fad.tar.gz scala-560b3728f364f3523a2bad202d41881f719b9fad.tar.bz2 scala-560b3728f364f3523a2bad202d41881f719b9fad.zip |
Merge pull request #2798 from som-snytt/issue/7544-errmsg
SI-7544 Interpolation message for %% literal
-rw-r--r-- | src/compiler/scala/tools/reflect/MacroImplementations.scala | 3 | ||||
-rw-r--r-- | src/library/scala/StringContext.scala | 3 | ||||
-rw-r--r-- | test/files/neg/t7325.check | 10 | ||||
-rw-r--r-- | test/files/run/interpolation.flags | 1 | ||||
-rw-r--r-- | test/files/run/interpolationArgs.check | 4 | ||||
-rw-r--r-- | test/files/run/interpolationArgs.flags | 1 | ||||
-rw-r--r-- | test/files/run/interpolationMultiline1.flags | 1 | ||||
-rw-r--r-- | test/files/run/interpolationMultiline2.flags | 1 |
8 files changed, 11 insertions, 13 deletions
diff --git a/src/compiler/scala/tools/reflect/MacroImplementations.scala b/src/compiler/scala/tools/reflect/MacroImplementations.scala index 8e1bcb5f87..4e3761454d 100644 --- a/src/compiler/scala/tools/reflect/MacroImplementations.scala +++ b/src/compiler/scala/tools/reflect/MacroImplementations.scala @@ -94,7 +94,8 @@ abstract class MacroImplementations { def errorAtIndex(idx: Int, msg: String) = c.error(new OffsetPosition(strTree.pos.source, strTree.pos.point + idx), msg) def wrongConversionString(idx: Int) = errorAtIndex(idx, "wrong conversion string") def illegalConversionCharacter(idx: Int) = errorAtIndex(idx, "illegal conversion character") - def nonEscapedPercent(idx: Int) = errorAtIndex(idx, "percent signs not directly following splicees must be escaped") + def nonEscapedPercent(idx: Int) = errorAtIndex(idx, + "conversions must follow a splice; use %% for literal %, %n for newline") // STEP 1: handle argument conversion // 1) "...${smth}" => okay, equivalent to "...${smth}%s" diff --git a/src/library/scala/StringContext.scala b/src/library/scala/StringContext.scala index 42fb2f36e8..70f95750da 100644 --- a/src/library/scala/StringContext.scala +++ b/src/library/scala/StringContext.scala @@ -59,7 +59,8 @@ case class StringContext(parts: String*) { */ def checkLengths(args: Seq[Any]): Unit = if (parts.length != args.length + 1) - throw new IllegalArgumentException("wrong number of arguments for interpolated string") + throw new IllegalArgumentException("wrong number of arguments ("+ args.length + +") for interpolated string with "+ parts.length +" parts") /** The simple string interpolator. diff --git a/test/files/neg/t7325.check b/test/files/neg/t7325.check index 709ab6db3e..d2c40f4df8 100644 --- a/test/files/neg/t7325.check +++ b/test/files/neg/t7325.check @@ -1,19 +1,19 @@ -t7325.scala:2: error: percent signs not directly following splicees must be escaped +t7325.scala:2: error: conversions must follow a splice; use %% for literal %, %n for newline println(f"%") ^ -t7325.scala:4: error: percent signs not directly following splicees must be escaped +t7325.scala:4: error: conversions must follow a splice; use %% for literal %, %n for newline println(f"%%%") ^ -t7325.scala:6: error: percent signs not directly following splicees must be escaped +t7325.scala:6: error: conversions must follow a splice; use %% for literal %, %n for newline println(f"%%%%%") ^ t7325.scala:16: error: wrong conversion string println(f"${0}%") ^ -t7325.scala:19: error: percent signs not directly following splicees must be escaped +t7325.scala:19: error: conversions must follow a splice; use %% for literal %, %n for newline println(f"${0}%%%d") ^ -t7325.scala:21: error: percent signs not directly following splicees must be escaped +t7325.scala:21: error: conversions must follow a splice; use %% for literal %, %n for newline println(f"${0}%%%%%d") ^ 6 errors found diff --git a/test/files/run/interpolation.flags b/test/files/run/interpolation.flags deleted file mode 100644 index 48fd867160..0000000000 --- a/test/files/run/interpolation.flags +++ /dev/null @@ -1 +0,0 @@ --Xexperimental diff --git a/test/files/run/interpolationArgs.check b/test/files/run/interpolationArgs.check index 155991e618..983214cbee 100644 --- a/test/files/run/interpolationArgs.check +++ b/test/files/run/interpolationArgs.check @@ -1,2 +1,2 @@ -java.lang.IllegalArgumentException: wrong number of arguments for interpolated string -java.lang.IllegalArgumentException: wrong number of arguments for interpolated string +java.lang.IllegalArgumentException: wrong number of arguments (1) for interpolated string with 3 parts +java.lang.IllegalArgumentException: wrong number of arguments (1) for interpolated string with 1 parts diff --git a/test/files/run/interpolationArgs.flags b/test/files/run/interpolationArgs.flags deleted file mode 100644 index e1b37447c9..0000000000 --- a/test/files/run/interpolationArgs.flags +++ /dev/null @@ -1 +0,0 @@ --Xexperimental
\ No newline at end of file diff --git a/test/files/run/interpolationMultiline1.flags b/test/files/run/interpolationMultiline1.flags deleted file mode 100644 index 48fd867160..0000000000 --- a/test/files/run/interpolationMultiline1.flags +++ /dev/null @@ -1 +0,0 @@ --Xexperimental diff --git a/test/files/run/interpolationMultiline2.flags b/test/files/run/interpolationMultiline2.flags deleted file mode 100644 index e1b37447c9..0000000000 --- a/test/files/run/interpolationMultiline2.flags +++ /dev/null @@ -1 +0,0 @@ --Xexperimental
\ No newline at end of file |