Scala Programming Language
  1. Scala Programming Language
  2. SI-3755

interpreter crash with abstract types and pattern matching

    Details

      Description

      With the attached source file's classes in the classpath, this fails:

      scala> issue.Test1.t
      Exception in thread "main" scala.tools.nsc.symtab.Types$$MissingTypeControl
      

      (The interpreter has crashed here.)

      This succeeds further, but still fails:

      scala> issue.Test2
      res0: issue.Test2.type = issue.Test2$$@13dc4d5
      
      scala> issue.Test1.t
      res1: issue.Example = issue.Example@1f1a3a8
      
      scala> issue.Test1.t.example
      Exception in thread "main" scala.tools.nsc.symtab.Types$$MissingTypeControl
      

      More:

      scala> issue.Test1.t.example: issue.ENat
      res0: issue.ENat = issue.EZero$$@bd4dc2
      
      scala> issue.Test1.t                    
      res1: issue.Example = issue.Example@12620b5
      
      scala> issue.Test1.t.example            
      Exception in thread "main" scala.tools.nsc.symtab.Types$$MissingTypeControl
      

      Spelling out t's definition works the same as t. Everything seems to work fine if you uncomment the return type for example in the source.

        Activity

        Hide
        James Deikun added a comment -

        Nearly forgot:

        $$ scala-2.8.0.final/bin/scala -version
        Scala code runner version 2.8.0.final -- Copyright 2002-2010, LAMP/EPFL
        $$ java -version
        java version "1.6.0_18"
        OpenJDK Runtime Environment (IcedTea6 1.8) (6b18-1.8-4ubuntu3~9.04.2)
        OpenJDK Server VM (build 16.0-b13, mixed mode)
        
        Show
        James Deikun added a comment - Nearly forgot: $$ scala-2.8.0.final/bin/scala -version Scala code runner version 2.8.0.final -- Copyright 2002-2010, LAMP/EPFL $$ java -version java version "1.6.0_18" OpenJDK Runtime Environment (IcedTea6 1.8) (6b18-1.8-4ubuntu3~9.04.2) OpenJDK Server VM (build 16.0-b13, mixed mode)
        Hide
        Ben Hardy added a comment -

        I have been able to cause similar crashes which seem related to type handling in the REPL. in the REPL both in 2.8.0-final and in the latest 2.9.0 nightly build, though the exceptions in each case look different. I was running the following code in the REPL. Also tested on compiled files - this error doesn't occur there so I assume this is REPL specified.

        case class Gender(rep:String) {
          override def toString = rep
        }
        case class Male extends Gender("Male")
        case class Female extends Gender("Female")
        

        In both 2.8.0 and 2.9.0 the output looks like this:

        $$ ./scala -deprecation
        Welcome to Scala version 2.8.0.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_20).
        Type in expressions to have them evaluated.
        Type :help for more information.
        
        scala> case class Gender(rep:String) {
             |   override def toString = rep
             | }
        defined class Gender
        
        scala> case class Male extends Gender("Male")
        <console>:1: warning: case classes without a parameter list have been deprecated;
        use either case objects or case classes with `()' as parameter list.
               case class Male extends Gender("Male")
                               ^
        <console>:7: warning: case classes without a parameter list have been deprecated;
        use either case objects or case classes with `()' as parameter list.
               case class Male extends Gender("Male")
                               ^
        <console>:7: warning: case class `class Male' has case class ancestor `class Gender'.  
        This has been deprecated for unduly complicating both usage and implementation.  
        You should instead use extractors for pattern matching on non-leaf nodes.
               case class Male extends Gender("Male")
                          ^
        defined class Male
        
        scala> case class Female extends Gender("Female")
        <console>:1: warning: case classes without a parameter list have been deprecated;
        use either case objects or case classes with `()' as parameter list.
               case class Female extends Gender("Female")
                                 ^
        <console>:7: warning: case classes without a parameter list have been deprecated;
        use either case objects or case classes with `()' as parameter list.
               case class Female extends Gender("Female")
                                 ^
        <console>:7: warning: case class `class Female' has case class ancestor `class Gender'.  
        This has been deprecated for unduly complicating both usage and implementation.  
        You should instead use extractors for pattern matching on non-leaf nodes.
               case class Female extends Gender("Female")
                          ^
        

        2.8.0 stacktrace here: http://pastebin.com/JT8kbBrX
        [[BR]]
        2.9.0 stacktrace here: http://pastebin.com/Z31Xqw9e

        Show
        Ben Hardy added a comment - I have been able to cause similar crashes which seem related to type handling in the REPL. in the REPL both in 2.8.0-final and in the latest 2.9.0 nightly build, though the exceptions in each case look different. I was running the following code in the REPL. Also tested on compiled files - this error doesn't occur there so I assume this is REPL specified. case class Gender(rep:String) { override def toString = rep } case class Male extends Gender("Male") case class Female extends Gender("Female") In both 2.8.0 and 2.9.0 the output looks like this: $$ ./scala -deprecation Welcome to Scala version 2.8.0.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_20). Type in expressions to have them evaluated. Type :help for more information. scala> case class Gender(rep:String) { | override def toString = rep | } defined class Gender scala> case class Male extends Gender("Male") <console>:1: warning: case classes without a parameter list have been deprecated; use either case objects or case classes with `()' as parameter list. case class Male extends Gender("Male") ^ <console>:7: warning: case classes without a parameter list have been deprecated; use either case objects or case classes with `()' as parameter list. case class Male extends Gender("Male") ^ <console>:7: warning: case class `class Male' has case class ancestor `class Gender'. This has been deprecated for unduly complicating both usage and implementation. You should instead use extractors for pattern matching on non-leaf nodes. case class Male extends Gender("Male") ^ defined class Male scala> case class Female extends Gender("Female") <console>:1: warning: case classes without a parameter list have been deprecated; use either case objects or case classes with `()' as parameter list. case class Female extends Gender("Female") ^ <console>:7: warning: case classes without a parameter list have been deprecated; use either case objects or case classes with `()' as parameter list. case class Female extends Gender("Female") ^ <console>:7: warning: case class `class Female' has case class ancestor `class Gender'. This has been deprecated for unduly complicating both usage and implementation. You should instead use extractors for pattern matching on non-leaf nodes. case class Female extends Gender("Female") ^ 2.8.0 stacktrace here: http://pastebin.com/JT8kbBrX [ [BR] ] 2.9.0 stacktrace here: http://pastebin.com/Z31Xqw9e
        Hide
        Paul Phillips added a comment -

        I don't think this (the original submission) is a repl issue, though I'm open to pointers if it is. I sent an email to scala-internals vaguely referencing this, but I think it's related to the business in SI-3731.

        The case class crash mentioned in comments is gone.

        Show
        Paul Phillips added a comment - I don't think this (the original submission) is a repl issue, though I'm open to pointers if it is. I sent an email to scala-internals vaguely referencing this, but I think it's related to the business in SI-3731 . The case class crash mentioned in comments is gone.
        Hide
        Adriaan Moors added a comment -
        Show
        Adriaan Moors added a comment - fixed by https://github.com/scala/scala/pull/445

          People

          • Assignee:
            Adriaan Moors
            Reporter:
            James Deikun
            TracCC:
            Ben Hardy, Paul Phillips
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development