Skip to content

Reinstate deprecation of unicode arrows ( & ) #13226

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

Closed
Closed
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
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/parsing/Scanners.scala
Original file line number Diff line number Diff line change
Expand Up @@ -879,9 +879,11 @@ object Scanners {
case _ =>
def fetchOther() =
if (ch == '\u21D2') {
report.deprecationWarning("The unicode arrow `⇒` is deprecated, use `=>` instead. If you still wish to display it as one character, consider using a font with programming ligatures such as Fira Code.", sourcePos(offset))
nextChar(); token = ARROW
}
else if (ch == '\u2190') {
report.deprecationWarning("The unicode arrow `←` is deprecated, use `<-` instead. If you still wish to display it as one character, consider using a font with programming ligatures such as Fira Code.", sourcePos(offset))
nextChar(); token = LARROW
}
else if (Character.isUnicodeIdentifierStart(ch)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ object ImpliedInstances {

def apply[A](using parser: StringParser[A]): StringParser[A] = parser

private def baseParser[A](f: String Try[A]): StringParser[A] = new StringParser[A] {
private def baseParser[A](f: String => Try[A]): StringParser[A] = new StringParser[A] {
override def parse(s: String): Try[A] = f(s)
}

given stringParser: StringParser[String] = baseParser(Success(_))
given intParser: StringParser[Int] = baseParser(s Try(s.toInt))
given intParser: StringParser[Int] = baseParser(s => Try(s.toInt))

given optionParser[A](using parser: => StringParser[A]): StringParser[Option[A]] = new StringParser[Option[A]] {
override def parse(s: String): Try[Option[A]] = s match {
case "" Success(None) // implicit parser not used.
case str parser.parse(str).map(x Some(x)) // implicit parser is evaluated at here
case "" => Success(None) // implicit parser not used.
case str => parser.parse(str).map(x => Some(x)) // implicit parser is evaluated at here
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion scaladoc/src/dotty/tools/scaladoc/util/JSON.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def jsonString(s: String): JSON =

sb.append('"')
firstToBeEncoded() match
case -1 sb.append(s)
case -1 => sb.append(s)
case first =>
// sb.append(s, 0, first) for "abc", 0, 2 produce "(abc,0,2)" rather then "ab" as in Java
sb.append(s.substring(0, first))
Expand Down
6 changes: 3 additions & 3 deletions tests/disabled/macro/run/t7240/Macros_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ object Bakery {

val tpeName = newTypeName(names.head)
names.tail.reverse match {
case head :: tail
Select(tail.foldLeft[Tree](Ident(newTermName(head)))((tree, name) Select(tree, newTermName(name))), tpeName)
case Nil
case head :: tail =>
Select(tail.foldLeft[Tree](Ident(newTermName(head)))((tree, name) => Select(tree, newTermName(name))), tpeName)
case Nil =>
Ident(tpeName)
}
}
Expand Down
14 changes: 7 additions & 7 deletions tests/patmat/t11620.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ object B {
}

def foo[T](b: B[T]) = b match {
case B(A1(t)) t
case B(A2(t, _)) t
case B(A1(t)) => t
case B(A2(t, _)) => t
}

def foo2[_A[+U] <: A[U], T](b: B.Aux[_A, T]) = b match {
case B.Aux(a @ A1(_ )) a.t
case B.Aux(a @ A2(_, _)) a.t1 // 👎 (false-positive): unreachable code
case B.Aux(a @ A1(_ )) => a.t
case B.Aux(a @ A2(_, _)) => a.t1 // 👎 (false-positive): unreachable code
}

def foo3[_A[+U] <: A[U], T](b: B.Aux[_A, T]) = b match {
case B.Aux(a: A1[T]) a.t
case B.Aux(a: A2[T]) a.t1 // 👎 (false-positive): unreachable code
case B.Aux(a: A1[T]) => a.t
case B.Aux(a: A2[T]) => a.t1 // 👎 (false-positive): unreachable code
}

def foo4[T](b: B[T]) = b match {
case B(A1(t)) t // 👎 (false-negative): incomplete match
case B(A1(t)) => t // 👎 (false-negative): incomplete match
}
2 changes: 1 addition & 1 deletion tests/pending/i12194.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ def f(): Unit =

@main def Test(): Unit =
println(summonAll[Tuple.Map[("foo", "bar"), ValueOf]].toList.map{
case str: ValueOf[_] str.value
case str: ValueOf[_] => str.value
})
2 changes: 1 addition & 1 deletion tests/pending/pos/TypeIndexing.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

object Test {
def use(a : A) = a match {
case b @ A(t)
case b @ A(t) =>
val s: b.T = t // type mismatch.
// found t.type (with underlying type <unapply-selector>.T)
// required: a.T
Expand Down
2 changes: 1 addition & 1 deletion tests/pending/run/t8091.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
object Test extends App {
val result = "börk börk" flatMap (ch if (ch > 127) f"&#x${ch}%04x;" else "" + ch)
val result = "börk börk" flatMap (ch => if (ch > 127) f"&#x${ch}%04x;" else "" + ch)
println(result)
}
Binary file modified tests/pos-special/utf16encoded.scala
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/run/cochis.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ trait A {
def trans[A] (x : A) (implicit f : A => A) = f(x)
}
object Test extends A with App {
implicit def succ : Int Int = x x + 1 // (3)
implicit def succ : Int => Int = x => x + 1 // (3)
def bad [A] (x : A) : A = trans[A](x) // (4) incoherent de€nition !
val v1 = bad [Int] (3) // (5) evaluates to 3
val v2 = trans [Int] (3) // (6) substituting bad by trans is rejected
Expand Down