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 loops infinitely[on multiple cores] when anon Iterator object tries to store 'this' #8865

Closed
scabug opened this issue Sep 27, 2014 · 2 comments
Milestone

Comments

@scabug
Copy link

scabug commented Sep 27, 2014

Attempting to compile the following code will cause scalac to spin fruitlessly on multiple cores until the JVM runs out of memory

class Point{
  def iter =
    new Iterator[Point]{
      var currentPosition = this
      def next:Point = currentPosition
      def hasNext:Boolean = true
    }
}

This appears to be due to the var currentPosition = this [when I introduced the bug into the code base I guess I was thinking 'this' would refer to the Point, it does not, of course. The compiler should complain at def next...]

@scabug
Copy link
Author

scabug commented Sep 27, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8865?orig=1
Reporter: mako yass (makoConstruct)
Affected Versions: 2.9.2, 2.10.2
Duplicates #8158

@scabug
Copy link
Author

scabug commented Sep 27, 2014

@gourlaysama said:
That's a duplicate of #8158 (although that ticket's title seem to imply it is about macros, it is more general than that, see comments): the compiler hangs while trying to print the error message in that code.

In 2.11.2, this prints:

test.scala:5: error: type mismatch;
 found   : Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[Point]{def currentPosition: $anon; def currentPosition_=(x$1: Iterator[...]{def currentPosition: $anon; def currentPosition_=(x$1: ...{def currentPosition: $anon; def currentPosition_=(x$1: ...): ...}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}): Unit}
 required: Point
      def next:Point = currentPosition
                       ^
one error found

It was fixed in v2.11.0-RC1 (in 936d60a).

@scabug scabug closed this as completed Sep 27, 2014
@scabug scabug added this to the 2.11.0-RC1 milestone Apr 7, 2017
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

1 participant