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

compiler crash rather than message "XXZ is not an enclosing class" in erroneous code #8534

Closed
scabug opened this issue Apr 24, 2014 · 10 comments

Comments

@scabug
Copy link

scabug commented Apr 24, 2014

Welcome to Scala version 2.11.0 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0).
Type in expressions to have them evaluated.
Type :help for more information.

scala> trait MyTrait {type T; case class SomeData(x: T)}
defined trait MyTrait

scala> class BugTest {def isTheBugHere(in: MyTrait.this.type#SomeData) = false}
:7: error: MyTrait is not an enclosing class
class BugTest {def isTheBugHere(in: MyTrait.this.type#SomeData) = false}
^

@scabug
Copy link
Author

scabug commented Apr 24, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8534?orig=1
Reporter: Igor Rumiha (igorrumiha)
Affected Versions: 2.10.3, 2.11.0
Attachments:

@scabug
Copy link
Author

scabug commented Apr 24, 2014

@adriaanm said:
The error message is correct. BugTest is not nested in MyTrait.

PS: I recommend putting the opening brace on the same line as the class definition, as in

trait MyTrait {
...

@scabug
Copy link
Author

scabug commented Apr 24, 2014

@adriaanm said:
This works:

trait MyTrait { type T; case class SomeData(x: T) }
class BugTest {
  def isTheBugHere(in: MyTrait#SomeData) = false
 }

@scabug
Copy link
Author

scabug commented Apr 25, 2014

Igor Rumiha (igorrumiha) said:
I know the code is not correct as it is, so an error message from the compiler is expected. Nevertheless, a large stack trace and a "You have slain the compiler" message seemed to be reason enough to report a bug.

@scabug
Copy link
Author

scabug commented Apr 25, 2014

@retronym said:
Crashiness was induced in scala/scala#2374 / v2.11.0-M3~16

@scabug
Copy link
Author

scabug commented Apr 25, 2014

@retronym said:

object line1 {
  trait MyTrait
}
object line2 {
  import line2._
  class BugTest {def isTheBugHere(in: MyTrait.this.type#SomeData) = false}
}
scalac-hash v2.11.0-M3~17 sandbox/test.scala
sandbox/test.scala:6: error: MyTrait is not an enclosing class
  class BugTest {def isTheBugHere(in: MyTrait.this.type#SomeData) = false}
                                      ^
one error found

% scalac-hash v2.11.0-M3~16 sandbox/test.scala
sandbox/test.scala:6: error: MyTrait is not an enclosing class
  class BugTest {def isTheBugHere(in: MyTrait.this.type#SomeData) = false}
                                      ^
uncaught exception during compilation: AssertionError("assertion failed: <error: value <error: <none>>>.this") @ scala.reflect.internal.Trees$SelectFromTypeTree.<init>(Trees.scala:502)
error: java.lang.AssertionError: assertion failed: <error: value <error: <none>>>.this
error:

@scabug
Copy link
Author

scabug commented Apr 25, 2014

@retronym said:
Assigning to Adriaan.

@scabug
Copy link
Author

scabug commented Apr 25, 2014

@adriaanm said:
Apologies, I didn't realize we were talking compiler crash.

@scabug
Copy link
Author

scabug commented Nov 4, 2014

@retronym said:
Reassinging to 2.11.5, 2.11.4 has already been released.

@scabug
Copy link
Author

scabug commented Nov 8, 2014

@retronym said:
scala/scala#4114

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