Scala Programming Language
  1. Scala Programming Language
  2. SI-3501

java.lang.Error: no-symbol does not have owner with CPS-Plugin

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Misc Compiler
    • Labels:
      None
    • Environment:

      continuations cps selectivecps

      Description

      The following code raises the error:

      java.lang.Error: no-symbol does not have owner
              at scala.tools.nsc.symtab.SymbolTable.abort(SymbolTable.scala:33)
              at scala.tools.nsc.symtab.Symbols$$NoSymbol$$.owner(Symbols.scala:2048)
              at
      scala.tools.nsc.transform.ExplicitOuter$$OuterPathTransformer.outerSelect(ExplicitOuter.scala:190)
              at
      scala.tools.nsc.transform.ExplicitOuter$$OuterPathTransformer.outerPath(ExplicitOuter.scala:217)
              at
      scala.tools.nsc.transform.ExplicitOuter$$ExplicitOuterTransformer.transform(ExplicitOuter.scala:456)
              at
      scala.tools.nsc.ast.Trees$$Transformer$$$$anonfun$$transform$$4.apply(Trees.scala:736)
              at
      scala.tools.nsc.ast.Trees$$Transformer$$$$anonfun$$transform$$4.apply(Trees.scala:735)
              at scala.tools.nsc.ast.Trees$$Transformer.atOwner(Trees.scala:856)
              at
      scala.tools.nsc.transform.TypingTransformers$$TypingTransformer.atOwner(TypingTransformers.scala:35)
              at
      scala.tools.nsc.transform.TypingTransformers$$TypingTransformer.atOwner(TypingTransformers.scala:28)
              at scala.tools.nsc.ast.Trees$$Transformer.transform(Trees.scala:734) 
      
      package test
      import scala.util.continuations._
      object NoSymbolTest {
         
        def sum(a: Int, b: Int): Int = a + b
       
        def main(args: Array[String]) = {
             
          def capture(): Int @suspendable =
            shift { k: (Int => Unit) => {
              k(42)
            }}
         
          def loop(): Unit @suspendable = {
            var x = 0
            while (x < 3) {
              val y = capture()
      //        val s = sum(x, y) // java.lang.Error: no-symbol does not have owner
      //        x = s
               x = sum(x,y) // WORKS
            }
            println("x: " + x)
          }
         
          reset[Unit,Unit] {
            loop()
          }
        }
      }
      

        Activity

        Hide
        Tiark Rompf added a comment -

        reducing it further:

        import scala.util.continuations._
        
        object Test {
        
          def capture(): Int @suspendable = 42
        
          def loop(): Unit @suspendable = {
            while (true) {
              val y = foo()
              val s = y // java.lang.Error: no-symbol does not have owner
            }
            // removing either 'val s = ' or replacing 'y' with
            // something else will make it work
          } 
        }
        
        Show
        Tiark Rompf added a comment - reducing it further: import scala.util.continuations._ object Test { def capture(): Int @suspendable = 42 def loop(): Unit @suspendable = { while (true) { val y = foo() val s = y // java.lang.Error: no-symbol does not have owner } // removing either 'val s = ' or replacing 'y' with // something else will make it work } }
        Hide
        Tiark Rompf added a comment -

        capture=foo. problem seems to be specific to right-hand sides of ValDefs within while loops. a possible workaround is to declare a var outside the loop and assign to that var within the loop.

        Show
        Tiark Rompf added a comment - capture=foo. problem seems to be specific to right-hand sides of ValDefs within while loops. a possible workaround is to declare a var outside the loop and assign to that var within the loop.
        Hide
        Tiark Rompf added a comment -

        See SI-3891 for another manifestation of this issue.

        Show
        Tiark Rompf added a comment - See SI-3891 for another manifestation of this issue.
        Hide
        Paul Phillips added a comment -

        Tiark – in case it should be useful, I call your attention to the recently rendered usable tree checker output. It is displeased that val tmp1's owner is not who it expects.

        % scalac  -Ycheck-debug -Ycheck:all  -P:continuations:enable a.scala  
        Created [REF(type AnyRef)]
        [Not checkable: parser]
        [Not checkable: namer]
        [Not checkable: packageobjects]
        [Now checking: typer]
        [check: typer] 19 new symbols.
        unhandled impoprt: import scala.util.continuations._ in a.scala
        [Now checking: superaccessors]
        unhandled impoprt: import scala.util.continuations._ in a.scala
        [Now checking: pickler]
        unhandled impoprt: import scala.util.continuations._ in a.scala
        [Now checking: refchecks]
        [Now checking: selectiveanf]
        [check: selectiveanf] 4 new symbols.
        [check: selectiveanf] a.scala:8: Expected owner method while$$1, found method loop: scala.reflect.generic.Trees$$ValDef / @scala.util.continuations.cpsSym <synthetic> val tmp1: Unit = {
          @scala.util.continuations.cpsSym val y: Int = Test.this.capture();
          val s: Int = y;
          ()
        }
        [Now checking: liftcode]
        [check: liftcode] a.scala:8: Expected owner method while$$1, found method loop: scala.reflect.generic.Trees$$ValDef / @scala.util.continuations.cpsSym <synthetic> val tmp1: Unit = {
          @scala.util.continuations.cpsSym val y: Int = Test.this.capture();
          val s: Int = y;
          ()
        }
        [Now checking: selectivecps]
        [check: selectivecps] 12 new symbols.
        [check: selectivecps] a.scala:10: Expected owner method while$$1, found method loop: scala.reflect.generic.Trees$$ValDef / val s: Int = y
        [...]
        
        Show
        Paul Phillips added a comment - Tiark – in case it should be useful, I call your attention to the recently rendered usable tree checker output. It is displeased that val tmp1's owner is not who it expects. % scalac -Ycheck-debug -Ycheck:all -P:continuations:enable a.scala Created [REF(type AnyRef)] [Not checkable: parser] [Not checkable: namer] [Not checkable: packageobjects] [Now checking: typer] [check: typer] 19 new symbols. unhandled impoprt: import scala.util.continuations._ in a.scala [Now checking: superaccessors] unhandled impoprt: import scala.util.continuations._ in a.scala [Now checking: pickler] unhandled impoprt: import scala.util.continuations._ in a.scala [Now checking: refchecks] [Now checking: selectiveanf] [check: selectiveanf] 4 new symbols. [check: selectiveanf] a.scala:8: Expected owner method while$$1, found method loop: scala.reflect.generic.Trees$$ValDef / @scala.util.continuations.cpsSym <synthetic> val tmp1: Unit = { @scala.util.continuations.cpsSym val y: Int = Test.this.capture(); val s: Int = y; () } [Now checking: liftcode] [check: liftcode] a.scala:8: Expected owner method while$$1, found method loop: scala.reflect.generic.Trees$$ValDef / @scala.util.continuations.cpsSym <synthetic> val tmp1: Unit = { @scala.util.continuations.cpsSym val y: Int = Test.this.capture(); val s: Int = y; () } [Now checking: selectivecps] [check: selectivecps] 12 new symbols. [check: selectivecps] a.scala:10: Expected owner method while$$1, found method loop: scala.reflect.generic.Trees$$ValDef / val s: Int = y [...]
        Hide
        Ingo Maier added a comment -

        In probably doesn't give any new insight, but I hit this issue with the following snippet:

        def f(): String @suspendable = ""
        reset { 
          while(true) { 
            val p = f.length // assignment and member access both critical
          }
        }
        
        Show
        Ingo Maier added a comment - In probably doesn't give any new insight, but I hit this issue with the following snippet: def f(): String @suspendable = "" reset { while(true) { val p = f.length // assignment and member access both critical } }
        Hide
        Topher added a comment -

        I've attached a patch, including a test case.

        Show
        Topher added a comment - I've attached a patch, including a test case.
        Hide
        Topher added a comment -

        Oh, the patch adds files, so you'll want to do:

        patch -p0 -i ~/tmp/t3501.patch
        svn add test/files/continuations-run/t3501.check test/files/continuations-run/t3501.scala

        Show
        Topher added a comment - Oh, the patch adds files, so you'll want to do: patch -p0 -i ~/tmp/t3501.patch svn add test/files/continuations-run/t3501.check test/files/continuations-run/t3501.scala
        Hide
        Commit Message Bot added a comment -

        (rompf in r25544) applying patch provided by Topher, fixes #3501. no review.

        Show
        Commit Message Bot added a comment - (rompf in r25544 ) applying patch provided by Topher, fixes #3501. no review.

          People

          • Assignee:
            Tiark Rompf
            Reporter:
            Kai Meder
            TracCC:
            Kai Meder, Miles Sabin, Paul Phillips
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development