# Breaking match change from Scala 2 to 3 that is too silent

**URL:** <https://contributors.scala-lang.org/t/breaking-match-change-from-scala-2-to-3-that-is-too-silent/5647>\
**Category:** Compiler\
**Created:** [March 15, 2022, 3:00pm UTC](https://contributors.scala-lang.org/t/breaking-match-change-from-scala-2-to-3-that-is-too-silent/5647 "2022-03-15T15:00:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![devlaam](https://contributors.scala-lang.org/user_avatar/contributors.scala-lang.org/devlaam/32/2395_2.png) [@devlaam](https://contributors.scala-lang.org/u/devlaam)\
**Post date:** [March 15, 2022, 3:00pm UTC](https://contributors.scala-lang.org/t/breaking-match-change-from-scala-2-to-3-that-is-too-silent/5647/1 "2022-03-15T15:00:53Z")

</div>

Consider the following code:

```scala
object MatchTest { 
  val a: Array[Long] = Array(1L)

  def test(x: Any) = x match { 
    case Array(i: Long) => println("Success!")
    case _ => println("Failure!") }

  def main(args: Array[String]): Unit = test(a) }

```

When run under [Scala 2.13.8](https://scastie.scala-lang.org/tEFTcPyhQ4CZCqo9nr183w) this produces `Success` whereas under [Scala 3.1.1](https://scastie.scala-lang.org/lBxvAXaEROmHNElxbaeBSQ) it produces `Failure`. For the latter [it does not matter](https://scastie.scala-lang.org/GBpXr4AKRe6uNyKhybXqIQ) if the compiler option `-source:3.0-migration` is used.

If the change is intended, this should at least produce a big fat **warning** that the match will possibly fail. If it is not intended, well … it’s even worse, for this significantly changes runtime behaviour after migration. I could not find a page in the [migration documentation](https://docs.scala-lang.org/scala3/guides/migration/compatibility-intro.html) discussing this (the [matchable trait page](https://docs.scala-lang.org/scala3/reference/other-new-features/matchable.html) is related, but addresses a different problem).

Btw, if you [replace the relevant](https://scastie.scala-lang.org/vuO7eND9QP2bWoKaSKojlA) `Array` by `IArray` the result is again `Success`, but gives other warnings.

---

<div class="post-metadata">

**Author:** ![smarter](https://contributors.scala-lang.org/user_avatar/contributors.scala-lang.org/smarter/32/92_2.png) [@smarter](https://contributors.scala-lang.org/u/smarter)\
**Post date:** [March 15, 2022, 3:38pm UTC](https://contributors.scala-lang.org/t/breaking-match-change-from-scala-2-to-3-that-is-too-silent/5647/2 "2022-03-15T15:38:50Z")

</div>

Looks like a bug. Please open an issue at [Issues · lampepfl/dotty · GitHub](https://github.com/lampepfl/dotty/issues).

---

<div class="post-metadata">

**Author:** ![devlaam](https://contributors.scala-lang.org/user_avatar/contributors.scala-lang.org/devlaam/32/2395_2.png) [@devlaam](https://contributors.scala-lang.org/u/devlaam)\
**Post date:** [March 15, 2022, 4:06pm UTC](https://contributors.scala-lang.org/t/breaking-match-change-from-scala-2-to-3-that-is-too-silent/5647/3 "2022-03-15T16:06:59Z")

</div>

Thanks for confirming, entry can be found under [Missed match on Array(1L) in Scala 3.1.1](https://github.com/lampepfl/dotty/issues/14693)

---

<div class="post-metadata">

**Author:** ![hepin1989](https://contributors.scala-lang.org/user_avatar/contributors.scala-lang.org/hepin1989/32/419_2.png) [@hepin1989](https://contributors.scala-lang.org/u/hepin1989)\
**Post date:** [March 15, 2022, 4:09pm UTC](https://contributors.scala-lang.org/t/breaking-match-change-from-scala-2-to-3-that-is-too-silent/5647/4 "2022-03-15T16:09:08Z")

</div>

This kind of runtime behavior change is very dangerous,thanks.
