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

Scala 2.13 failing to emit code that works with previous Scala versions #11609

Open
pweisenburger opened this issue Jul 3, 2019 · 3 comments

Comments

Projects
None yet
5 participants
@pweisenburger
Copy link

commented Jul 3, 2019

The following code (using Shapeless) compiles fine with Scala 2.11.x and 2.12.x. However, it fails to compile with Scala 2.13.0:

import shapeless._
import syntax.zipper._

object test {
  identity {
    val l = 1 :: "foo" :: 3.0 :: HNil
    val a0 = l.toZipper.right.put(("wibble", 45)).reify
  }
}

The compiler error is

[error] Error while emitting Test.scala
[error] value l

This might be related to missing stabilizers.

@lrytz

This comment has been minimized.

Copy link
Member

commented Jul 3, 2019

With -Vprint:typer -Ydebug:

                <module> object test extends scala.AnyRef {
                  <method> def <init>(): $iw.this.test.type = {
                    test.super[scala.this.AnyRef].<init>();
                    ()
                  };
                  {
                    <synthetic> <stable> <artifact> val stabilizer$3: shapeless.this.Zipper[shapeless.this.$colon$colon[scala.this.Int,shapeless.this.$colon$colon[scala.this.Tuple2[lang.this.String,scala.this.Int],shapeless.this.$colon$colon[scala.this.Double,shapeless.this.HNil]]],shapeless.this.$colon$colon[scala.this.Int,shapeless.this.HNil],shapeless.this.$colon$colon[scala.this.Tuple2[lang.this.String,scala.this.Int],shapeless.this.$colon$colon[scala.this.Double,shapeless.this.HNil]],scala.this.None.type] @annotations.this.uncheckedBounds = {
                      <synthetic> <stable> <artifact> val stabilizer$1: shapeless.this.Zipper[shapeless.this.$colon$colon[scala.this.Int,shapeless.this.$colon$colon[lang.this.String,shapeless.this.$colon$colon[scala.this.Double,shapeless.this.HNil]]],shapeless.this.HNil,shapeless.this.$colon$colon[scala.this.Int,shapeless.this.$colon$colon[lang.this.String,shapeless.this.$colon$colon[scala.this.Double,shapeless.this.HNil]]],scala.this.None.type] @annotations.this.uncheckedBounds = shapeless.syntax.zipper.toZipper[shapeless.this.$colon$colon[scala.this.Int,shapeless.this.$colon$colon[lang.this.String,shapeless.this.$colon$colon[scala.this.Double,shapeless.this.HNil]]]](l).toZipper;
                      <synthetic> <stable> <artifact> val stabilizer$2: shapeless.this.Zipper[shapeless.this.$colon$colon[scala.this.Int,shapeless.this.$colon$colon[lang.this.String,shapeless.this.$colon$colon[scala.this.Double,shapeless.this.HNil]]],shapeless.this.$colon$colon[scala.this.Int,shapeless.this.HNil],shapeless.this.$colon$colon[lang.this.String,shapeless.this.$colon$colon[scala.this.Double,shapeless.this.HNil]],scala.this.None.type] @annotations.this.uncheckedBounds = stabilizer$1.right(zipper.this.Right.right[shapeless.this.$colon$colon[scala.this.Int,shapeless.this.$colon$colon[lang.this.String,shapeless.this.$colon$colon[scala.this.Double,shapeless.this.HNil]]], shapeless.this.HNil, scala.this.Int, shapeless.this.$colon$colon[lang.this.String,shapeless.this.$colon$colon[scala.this.Double,shapeless.this.HNil]], scala.this.None.type]);
                      stabilizer$2.put[scala.this.Tuple2[lang.this.String,scala.this.Int]](scala.Tuple2.apply[lang.this.String, scala.this.Int]("wibble", 45))(zipper.this.Put.hlistPut[shapeless.this.$colon$colon[scala.this.Int,shapeless.this.$colon$colon[lang.this.String,shapeless.this.$colon$colon[scala.this.Double,shapeless.this.HNil]]], shapeless.this.$colon$colon[scala.this.Int,shapeless.this.HNil], lang.this.String, shapeless.this.$colon$colon[scala.this.Double,shapeless.this.HNil], scala.this.None.type, scala.this.Tuple2[lang.this.String,scala.this.Int], <refinement>.this.Out](hlist.this.ReversePrepend.hlistReversePrepend[scala.this.Int, shapeless.this.HNil, shapeless.this.$colon$colon[scala.this.Tuple2[lang.this.String,scala.this.Int],shapeless.this.$colon$colon[scala.this.Double,shapeless.this.HNil]]](hlist.this.ReversePrepend.hnilReversePrepend1[shapeless.this.HNil, shapeless.this.$colon$colon[scala.this.Int,shapeless.this.$colon$colon[scala.this.Tuple2[lang.this.String,scala.this.Int],shapeless.this.$colon$colon[scala.this.Double,shapeless.this.HNil]]]])))
                    };
                    scala.Predef.identity[scala.this.Unit]({
                      <triedcooking> val l: shapeless.this.$colon$colon[scala.this.Int,shapeless.this.$colon$colon[lang.this.String,shapeless.this.$colon$colon[scala.this.Double,shapeless.this.HNil]]] = {
                        shapeless.this.HList.hlistOps[shapeless.this.$colon$colon[lang.this.String,shapeless.this.$colon$colon[scala.this.Double,shapeless.this.HNil]]]({
  shapeless.this.HList.hlistOps[shapeless.this.$colon$colon[scala.this.Double,shapeless.this.HNil]]({
  shapeless.HNil.$colon$colon[scala.this.Double](3.0)
}).$colon$colon[lang.this.String]("foo")
}).$colon$colon[scala.this.Int](1)
                      };
                      val a0: shapeless.this.$colon$colon[scala.this.Int,shapeless.this.$colon$colon[scala.this.Tuple2[lang.this.String,scala.this.Int],shapeless.this.$colon$colon[scala.this.Double,shapeless.this.HNil]]] = stabilizer$3.reify(zipper.this.Reify.hlistReify[shapeless.this.$colon$colon[scala.this.Int,shapeless.this.$colon$colon[scala.this.Tuple2[lang.this.String,scala.this.Int],shapeless.this.$colon$colon[scala.this.Double,shapeless.this.HNil]]], shapeless.this.$colon$colon[scala.this.Int,shapeless.this.HNil], shapeless.this.$colon$colon[scala.this.Tuple2[lang.this.String,scala.this.Int],shapeless.this.$colon$colon[scala.this.Double,shapeless.this.HNil]], scala.this.None.type](hlist.this.ReversePrepend.hlistReversePrepend[scala.this.Int, shapeless.this.HNil, shapeless.this.$colon$colon[scala.this.Tuple2[lang.this.String,scala.this.Int],shapeless.this.$colon$colon[scala.this.Double,shapeless.this.HNil]]](hlist.this.ReversePrepend.hnilReversePrepend1[shapeless.this.HNil, shapeless.this.$colon$colon[scala.this.Int,shapeless.this.$colon$colon[scala.this.Tuple2[lang.this.String,scala.this.Int],shapeless.this.$colon$colon[scala.this.Double,shapeless.this.HNil]]]])));
                      ()
                    })
                  }
                }
java.util.NoSuchElementException: value l
	at scala.collection.mutable.AnyRefMap$ExceptionDefault.apply(AnyRefMap.scala:497)
	at scala.collection.mutable.AnyRefMap$ExceptionDefault.apply(AnyRefMap.scala:496)
	at scala.collection.mutable.AnyRefMap.apply(AnyRefMap.scala:206)
	at scala.tools.nsc.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder$locals$.load(BCodeSkelBuilder.scala:430)
	at scala.tools.nsc.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoad(BCodeBodyBuilder.scala:361)
	at scala.tools.nsc.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.$anonfun$genLoadArguments$1(BCodeBodyBuilder.scala:924)
	at scala.tools.nsc.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoadArguments(BCodeBodyBuilder.scala:924)

It seems the definition val stabilizer$1 tries to read l, but l is defined in an inner scope.

cc @milessabin

@som-snytt

This comment has been minimized.

Copy link

commented Jul 3, 2019

I'll take a "stab" at it, heh heh, stabilization pun. The linked PR doesn't fix it.

Edit: maybe it's fooled by the rassoc rewrite. Coincidentally, I've forgotten how that works.

@som-snytt

This comment has been minimized.

Copy link

commented Jul 9, 2019

It seems the newly linked PR is WIP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.