diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/util/NameTransformer.scala | 9 | ||||
-rw-r--r-- | test/files/pos/unicode-decode.scala | 9 |
2 files changed, 14 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/util/NameTransformer.scala b/src/compiler/scala/tools/nsc/util/NameTransformer.scala index 855b2d563d..f57334e362 100644 --- a/src/compiler/scala/tools/nsc/util/NameTransformer.scala +++ b/src/compiler/scala/tools/nsc/util/NameTransformer.scala @@ -109,11 +109,12 @@ object NameTransformer { } /* Handle the decoding of Unicode glyphs that are * not valid Java/JVM identifiers */ - } else if (ch1 == 'u' && - (Character.isDigit(ch2)) || - ('A' <= ch2 && ch2 <= 'F')) { + } else if ((len - i) >= 6 && // Check that there are enough characters left + ch1 == 'u' && + (Character.isDigit(ch2)) || + ('A' <= ch2 && ch2 <= 'F')) { /* Skip past "$u", next four should be hexadecimal */ - val hex = name.substring(i+2, if (i+6 <= len) i+6 else len) + val hex = name.substring(i+2, i+6) try { val str = Integer.parseInt(hex, 16).toChar if (buf eq null) { diff --git a/test/files/pos/unicode-decode.scala b/test/files/pos/unicode-decode.scala new file mode 100644 index 0000000000..9818ed64a4 --- /dev/null +++ b/test/files/pos/unicode-decode.scala @@ -0,0 +1,9 @@ +object Test { + + val ↑ = 3 + val x$u20A2 = 4 + val y$ub = 5 + val y$u0A = 6 + val z$up = 2 + +} |