Skip to content

Remove octal escape literals #11140

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

Merged
merged 1 commit into from
Jan 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions compiler/src/dotty/tools/dotc/parsing/Scanners.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,7 @@ object Scanners {
if (ch == '\\') {
nextChar()
if ('0' <= ch && ch <= '7') {
val start = charOffset - 2
val leadch: Char = ch
var oct: Int = digit2int(ch, 8)
nextChar()
Expand All @@ -1157,6 +1158,8 @@ object Scanners {
nextChar()
}
}
val alt = if oct == LF then raw"\n" else f"\u$oct%04x"
error(s"octal escape literals are unsupported: use $alt instead", start)
putChar(oct.toChar)
}
else if (ch == 'u' || ch == 'U') {
Expand Down
10 changes: 5 additions & 5 deletions tests/neg-custom-args/typeclass-derivation2.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ object TypeLevel {
val label: Array[Array[String]] =
initLabels(0, 0, new mutable.ArrayBuffer[String], new mutable.ArrayBuffer[Array[String]])

private final val elemSeparator = '\000'
private final val caseSeparator = '\001'
private final val elemSeparator = '\u0000'
private final val caseSeparator = '\u0001'

private def initLabels(start: Int, cur: Int,
elems: mutable.ArrayBuffer[String],
Expand Down Expand Up @@ -135,7 +135,7 @@ object Lst {
Shape.Case[Nil.type, EmptyTuple]
)]

val genericClass = new GenericClass("Cons\000hd\000tl\001Nil")
val genericClass = new GenericClass("Cons\u0000hd\u0000tl\u0001Nil")
import genericClass.mirror

val NilMirror = mirror(1)
Expand Down Expand Up @@ -165,7 +165,7 @@ object Pair {

type Shape[T] = Shape.Case[Pair[T], (T, T)]

val genericClass = new GenericClass("Pair\000x\000y")
val genericClass = new GenericClass("Pair\u0000x\u0000y")
import genericClass.mirror

implicit def pairShape[T]: Shaped[Pair[T], Shape[T]] = new {
Expand All @@ -189,7 +189,7 @@ object Either {
Shape.Case[Right[R], R *: EmptyTuple]
)]

val genericClass = new GenericClass("Left\000x\001Right\000x")
val genericClass = new GenericClass("Left\u0000x\u0001Right\u0000x")
import genericClass.mirror

implicit def eitherShape[L, R]: Shaped[Either[L, R], Shape[L, R]] = new {
Expand Down
12 changes: 12 additions & 0 deletions tests/neg/t7292-removal.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-- Error: tests/neg/t7292-removal.scala:2:14 ---------------------------------------------------------------------------
2 | val chr1 = '\0' // error
| ^
| octal escape literals are unsupported: use \u0000 instead
-- Error: tests/neg/t7292-removal.scala:3:17 ---------------------------------------------------------------------------
3 | val str1 = "abc\123456" // error
| ^
| octal escape literals are unsupported: use \u0053 instead
-- Error: tests/neg/t7292-removal.scala:4:12 ---------------------------------------------------------------------------
4 | val lf = '\012' // error
| ^
| octal escape literals are unsupported: use \n instead
5 changes: 5 additions & 0 deletions tests/neg/t7292-removal.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
object OctalEscapes {
val chr1 = '\0' // error
val str1 = "abc\123456" // error
val lf = '\012' // error
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved from untried

30 changes: 0 additions & 30 deletions tests/pending/run/t8266-octal-interp.check

This file was deleted.

1 change: 0 additions & 1 deletion tests/pending/run/t8266-octal-interp.flags

This file was deleted.

16 changes: 0 additions & 16 deletions tests/pending/run/t8266-octal-interp.scala

This file was deleted.

2 changes: 0 additions & 2 deletions tests/run/richs.check
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
RichCharTest1:
true
true
true
true

RichIntTest:
10
Expand Down
2 changes: 0 additions & 2 deletions tests/run/richs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ trait RichTest {
object RichCharTest1 extends RichTest {
def run: Unit = {
println("\n" + getObjectName + ":")
println('\40'.isWhitespace)
println('\011'.isWhitespace)
println('1'.asDigit == 1)
println('A'.asDigit == 10)
}
Expand Down
10 changes: 5 additions & 5 deletions tests/run/typeclass-derivation2a.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ object TypeLevel {
def mirror(ordinal: Int): Mirror =
mirror(ordinal, EmptyProduct)

private final val elemSeparator = '\000'
private final val caseSeparator = '\001'
private final val elemSeparator = '\u0000'
private final val caseSeparator = '\u0001'

val label: Array[Array[String]] =
initLabels(0, 0, new mutable.ArrayBuffer[String], new mutable.ArrayBuffer[Array[String]])
Expand Down Expand Up @@ -123,7 +123,7 @@ object Lst {
// common compiler-generated infrastructure
import TypeLevel._

val genericClass = new GenericClass("Cons\000hd\000tl\001Nil")
val genericClass = new GenericClass("Cons\u0000hd\u0000tl\u0001Nil")
import genericClass.mirror

private type ShapeOf[T] = Shape.Cases[(
Expand Down Expand Up @@ -158,7 +158,7 @@ object Pair {
// common compiler-generated infrastructure
import TypeLevel._

val genericClass = new GenericClass("Pair\000x\000y")
val genericClass = new GenericClass("Pair\u0000x\u0000y")
import genericClass.mirror

private type ShapeOf[T] = Shape.Case[Pair[T], (T, T)]
Expand Down Expand Up @@ -186,7 +186,7 @@ case class Right[R](x: R) extends Either[Nothing, R]
object Either {
import TypeLevel._

val genericClass = new GenericClass("Left\000x\001Right\000x")
val genericClass = new GenericClass("Left\u0000x\u0001Right\u0000x")
import genericClass.mirror

private type ShapeOf[L, R] = Shape.Cases[(
Expand Down
12 changes: 0 additions & 12 deletions tests/untried/neg/t7292-deprecation.check

This file was deleted.

1 change: 0 additions & 1 deletion tests/untried/neg/t7292-deprecation.flags

This file was deleted.

5 changes: 0 additions & 5 deletions tests/untried/neg/t7292-deprecation.scala

This file was deleted.

10 changes: 0 additions & 10 deletions tests/untried/neg/t7292-removal.check

This file was deleted.

1 change: 0 additions & 1 deletion tests/untried/neg/t7292-removal.flags

This file was deleted.

5 changes: 0 additions & 5 deletions tests/untried/neg/t7292-removal.scala

This file was deleted.