Skip to content

Fix ownership corruption problem in the awaited expression #210

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

Merged
merged 1 commit into from
Feb 8, 2019

Conversation

retronym
Copy link
Member

@retronym retronym commented Feb 7, 2019

Previously, whyDoYouHateMe was incorrectly owned by jerk,
rather than pointlessSymbolOwner after the ANF transform,
which in turn led to:

java.util.NoSuchElementException: value whyDoHateMe
    at scala.collection.mutable.AnyRefMap$ExceptionDefault.apply(AnyRefMap.scala:425)
    at scala.collection.mutable.AnyRefMap$ExceptionDefault.apply(AnyRefMap.scala:424)
    at scala.collection.mutable.AnyRefMap.apply(AnyRefMap.scala:180)
    at scala.tools.nsc.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder$locals$.load(BCodeSkelBuilder.scala:390)
    at scala.tools.nsc.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoad(BCodeBodyBuilder.scala:354)

@SethTisue
Copy link
Member

Previously, whyDoYouHateMe was incorrectly owned by jerk

best ticket ever

@pnf
Copy link

pnf commented Feb 7, 2019 via email

@hrhino
Copy link

hrhino commented Feb 7, 2019

Thank you!

I should start using more fanciful identifiers in my bug reports.

@pnf
Copy link

pnf commented Feb 7, 2019

Unfortunately, the following, which passed without the change to LateAnfTransform.scala, will now fail:

  @Test def testByNameOwner2(): Unit = {
    val result = run(
      """
      import scala.async.run.late.{autoawait,lateasync}
      object Bleh {
        @autoawait @lateasync def bleh = Bleh
        def byName[T](fn: => T): T = fn
      }
      object Boffo {
        @autoawait @lateasync def slob(): Unit = {
          val pointlessSymbolOwner =  {
              Bleh.bleh.byName {
                val whyDoHateMeToo = 1
                whyDoHateMeToo
              }
          }
        }
      }
      object Test {
        @lateasync def test() = Boffo.slob()
      }
      """)
  }

Previously, `whyDoYouHateMe` was incorrectly owned by `jerk`,
rather than `pointlessSymbolOwner` after the ANF transform,
which in turn led to:

```
java.util.NoSuchElementException: value whyDoHateMe
    at scala.collection.mutable.AnyRefMap$ExceptionDefault.apply(AnyRefMap.scala:425)
    at scala.collection.mutable.AnyRefMap$ExceptionDefault.apply(AnyRefMap.scala:424)
    at scala.collection.mutable.AnyRefMap.apply(AnyRefMap.scala:180)
    at scala.tools.nsc.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder$locals$.load(BCodeSkelBuilder.scala:390)
    at scala.tools.nsc.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoad(BCodeBodyBuilder.scala:354)
```
@retronym retronym force-pushed the topic/by-name-owner-bug branch from 63072fe to 103ec8c Compare February 7, 2019 22:38
@retronym
Copy link
Member Author

retronym commented Feb 7, 2019

@pnf Thanks for the test case. I've spotted the error in my first attempt and pushed a change that deals equally well with slobs and jerks. 😄

@retronym retronym merged commit 7236f3a into scala:master Feb 8, 2019
@retronym retronym added this to the 0.10 milestone Apr 8, 2019
retronym added a commit to retronym/scala that referenced this pull request Mar 24, 2020
retronym added a commit to retronym/scala that referenced this pull request Mar 24, 2020
retronym added a commit to retronym/scala that referenced this pull request Apr 20, 2020
retronym added a commit to retronym/scala that referenced this pull request Apr 20, 2020
retronym added a commit to retronym/scala that referenced this pull request Apr 20, 2020
retronym added a commit to retronym/scala that referenced this pull request Apr 20, 2020
retronym added a commit to retronym/scala that referenced this pull request Apr 28, 2020
retronym added a commit to retronym/scala that referenced this pull request Apr 29, 2020
retronym added a commit to retronym/scala that referenced this pull request May 11, 2020
retronym added a commit to retronym/scala that referenced this pull request Jun 1, 2020
retronym added a commit to retronym/scala that referenced this pull request Jun 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants