Details

    • Type: Bug
    • Status: CLOSED
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: Scala 2.9.0-1, Scala 2.9.2
    • Fix Version/s: Scala 2.10.0-M3, Scala 2.10.0
    • Component/s: Pattern Matcher
    • Labels:
      None
    • Environment:

      Tested on both 22-oct trunk (2.10.0.r25875-b20111022181326)
      and 2.9.0.1 from Ubuntu Oneiric

      Both on Java HotSpot(TM) Server VM, Java 1.6.0_24

      Description

      I think this deserves more than an "unchecked" warning:

      scala> def f {
           | val (n, l): (String, Int) = (4, "");
           | }
      warning: there were 2 unchecked warnings; re-run with -unchecked for details
      f: Unit
       
      scala> f
      java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
      [...]
      

      This is specially surprising because this other very similar case (created from SI-140, which I initially thought was the same bug) works as I expected:

      scala> def g {
           | val (n: String, l: Int) = (4, "");
           | }
      <console>:8: error: scrutinee is incompatible with pattern type;
       found   : String
       required: Int
             val (n: String, l: Int) = (4, "");
                     ^
      <console>:8: error: type mismatch;
       found   : String
       required: Int
             val (n: String, l: Int) = (4, "");
                   ^
      <console>:8: error: scrutinee is incompatible with pattern type;
       found   : Int
       required: String
             val (n: String, l: Int) = (4, "");
                                ^
      <console>:8: error: type mismatch;
       found   : Int
       required: String
             val (n: String, l: Int) = (4, "");
      

        Attachments

          Activity

            People

            • Assignee:
              moors Adriaan Moors
              Reporter:
              jsalvata Jordi Salvat i Alabart
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: