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 crashes on lazy list implementation #13349

Closed
MRandl opened this issue Aug 21, 2021 · 1 comment · Fixed by #13354
Closed

compiler crashes on lazy list implementation #13349

MRandl opened this issue Aug 21, 2021 · 1 comment · Fixed by #13354
Assignees
Milestone

Comments

@MRandl
Copy link

MRandl commented Aug 21, 2021

Compiler version

3.0.1, tested on macOS and Scastie

Minimized code

https://scastie.scala-lang.org/lCvA1ZJuSAahB7CATzl2cA

uncommenting the append function crashes the compiler.

exercise from the book "functional programming in scala"

Output

java.lang.UnsupportedOperationException: mkClosure(other.apply():�[35mPlayground.Stream[B]�[0m)

@dwijnand
Copy link
Member

dwijnand commented Aug 22, 2021

Minimised:

class Foo:
  def foo(x: => Foo) = bar(x: Foo)
  def bar(x: => Foo) = x
[[syntax trees at end of MegaPhase{firstTransform, checkReentrant, elimPackagePrefixes, cookComments, checkStatic, betaReduce, inlineVals, expandSAMs}]] // i13349min.scala
package <empty> {
  @scala.annotation.internal.SourceFile("i13349min.scala") class Foo() extends
    Object
  () {
    def foo(x: => Foo): Foo = this.bar(x:Foo)
    def bar(x: => Foo): Foo = x
  }
}

[[syntax trees at end of MegaPhase{elimRepeated, protectedAccessors, extmethods, uncacheGivenAliases, byNameClosures, hoistSuperArgs, specializeApplyMethods, refchecks, tryCatchPatterns, patternMatcher}]] // i13349min.scala: unchanged since MegaPhase{firstTransform, checkReentrant, elimPackagePrefixes, cookComments, checkStatic, betaReduce, inlineVals, expandSAMs}
exception occurred while compiling i13349min.scala
java.lang.UnsupportedOperationException: mkClosure(x.apply():Foo) while compiling i13349min.scala
Exception in thread "main" java.lang.UnsupportedOperationException: mkClosure(x.apply():Foo)
	at dotty.tools.package$.unsupported(package.scala:25)
	at dotty.tools.dotc.transform.TransformByNameApply.mkByNameClosure(TransformByNameApply.scala:37)
	at dotty.tools.dotc.transform.TransformByNameApply.transformArg$1(TransformByNameApply.scala:54)
	at dotty.tools.dotc.transform.TransformByNameApply.$anonfun$1(TransformByNameApply.scala:61)
	at dotty.tools.dotc.core.Decorators$ListDecorator$.zipWithConserve$extension(Decorators.scala:153)
	at dotty.tools.dotc.transform.TransformByNameApply.transformApply(TransformByNameApply.scala:61)
	at dotty.tools.dotc.transform.MegaPhase.goApply(MegaPhase.scala:644)
	at dotty.tools.dotc.transform.MegaPhase.goApply(MegaPhase.scala:645)
	at dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:281)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:429)
	at dotty.tools.dotc.transform.MegaPhase.mapDefDef$1(MegaPhase.scala:249)

@dwijnand dwijnand self-assigned this Aug 22, 2021
@dwijnand dwijnand linked a pull request Aug 22, 2021 that will close this issue
@Kordyjan Kordyjan added this to the 3.1.0 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants