Skip to content
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

interpreter crash with abstract types and pattern matching #3755

Closed
scabug opened this issue Aug 12, 2010 · 5 comments
Closed

interpreter crash with abstract types and pattern matching #3755

scabug opened this issue Aug 12, 2010 · 5 comments

Comments

@scabug
Copy link

scabug commented Aug 12, 2010

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.

@scabug
Copy link
Author

scabug commented Aug 12, 2010

Imported From: https://issues.scala-lang.org/browse/SI-3755?orig=1
Reporter: James Deikun (jdeikun)
Attachments:

  • t3755.scala (created on Aug 12, 2010 6:48:23 PM UTC, 559 bytes)

@scabug
Copy link
Author

scabug commented Aug 12, 2010

James Deikun (jdeikun) said:
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)

@scabug
Copy link
Author

scabug commented Sep 25, 2010

Ben Hardy (benhardy) said:
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]

@scabug
Copy link
Author

scabug commented Apr 24, 2011

@paulp said:
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 #3731.

The case class crash mentioned in comments is gone.

@scabug
Copy link
Author

scabug commented Apr 27, 2012

@adriaanm said:
fixed by scala/scala#445

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants