scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
232 stars 21 forks source link

Compiler error - symbol value ... does not exist #3366

Closed scabug closed 13 years ago

scabug commented 14 years ago

hi,

i am getting a compiler error with

"Error:Caused by java.lang.Error: symbol value player$$1 does not exist in de.sciss.synth.Buffer.play"

for the last change committed to http://github.com/Sciss/ScalaCollider (# f675b4b051969e9c4b852b444829b03eafd4cd2a )... the lines in charge are in de.sciss.synth.Buffer :

   def play( loop: Boolean = false, amp: Float = 1f, out: Int = 0 ) : Synth = {
      val player = PlayBuf.ar( numChannels, id, BufRateScale.kr( id ), loop = if( loop ) 1 else 0 )
      if( !loop ) FreeSelfWhenDone.kr( player )
      player * amp
   }.play( server, out )

the exception:

Information:Compilation completed with 44 errors and 0 warnings
Information:44 errors
Information:0 warnings
Error:Scalac internal error: class java.lang.reflect.InvocationTargetException [sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method), sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39), sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25), java.lang.reflect.Method.invoke(Method.java:597), org.jetbrains.plugins.scala.compiler.rt.ScalacRunner.main(ScalacRunner.java:74)][scala.tools.nsc.symtab.SymbolTable.abort(SymbolTable.scala:34), scala.tools.nsc.backend.icode.GenICode$$ICodePhase.scala$$tools$$nsc$$backend$$icode$$GenICode$$ICodePhase$$$$genLoad(GenICode.scala:844), scala.tools.nsc.backend.icode.GenICode$$ICodePhase.genLoadArguments(GenICode.scala:1031), scala.tools.nsc.backend.icode.GenICode$$ICodePhase.scala$$tools$$nsc$$backend$$icode$$GenICode$$ICodePhase$$$$genLoad(GenICode.scala:664), scala.tools.nsc.backend.icode.GenICode$$ICodePhase.scala$$tools$$nsc$$backend$$icode$$GenICode$$ICodePhase$$$$genLoad(GenICode.scala:878), scala.tools.nsc.backend.icode.GenICode$$ICodePhase.scala$$tools$$nsc$$backend$$icode$$GenICode$$ICodePhase$$$$genLoad(GenICode.scala:870), scala.tools.nsc.backend.icode.GenICode$$ICodePhase.genLoadArguments(GenICode.scala:1031), scala.tools.nsc.backend.icode.GenICode$$ICodePhase.scala$$tools$$nsc$$backend$$icode$$GenICode$$ICodePhase$$$$genLoad(GenICode.scala:743), scala.tools.nsc.backend.icode.GenICode$$ICodePhase.scala$$tools$$nsc$$backend$$icode$$GenICode$$ICodePhase$$$$genLoad(GenICode.scala:513), scala.tools.nsc.backend.icode.GenICode$$ICodePhase.scala$$tools$$nsc$$backend$$icode$$GenICode$$ICodePhase$$$$genStat(GenICode.scala:184), scala.tools.nsc.backend.icode.GenICode$$ICodePhase$$$$anonfun$$genStat$$1.apply(GenICode.scala:156), scala.tools.nsc.backend.icode.GenICode$$ICodePhase$$$$anonfun$$genStat$$1.apply(GenICode.scala:156), scala.collection.LinearSeqOptimized$$class.foldLeft(LinearSeqOptimized.scala:124), scala.collection.immutable.List.foldLeft(List.scala:46), scala.tools.nsc.backend.icode.GenICode$$ICodePhase.genStat(GenICode.scala:156), scala.tools.nsc.backend.icode.GenICode$$ICodePhase.scala$$tools$$nsc$$backend$$icode$$GenICode$$ICodePhase$$$$genLoad(GenICode.scala:869), scala.tools.nsc.backend.icode.GenICode$$ICodePhase.gen(GenICode.scala:127), scala.tools.nsc.backend.icode.GenICode$$ICodePhase$$$$anonfun$$gen$$1.apply(GenICode.scala:82), scala.tools.nsc.backend.icode.GenICode$$ICodePhase$$$$anonfun$$gen$$1.apply(GenICode.scala:82), scala.collection.LinearSeqOptimized$$class.foreach(LinearSeqOptimized.scala:62), scala.collection.immutable.List.foreach(List.scala:46), scala.tools.nsc.backend.icode.GenICode$$ICodePhase.gen(GenICode.scala:82), scala.tools.nsc.backend.icode.GenICode$$ICodePhase.gen(GenICode.scala:149), scala.tools.nsc.backend.icode.GenICode$$ICodePhase.gen(GenICode.scala:101), scala.tools.nsc.backend.icode.GenICode$$ICodePhase$$$$anonfun$$gen$$1.apply(GenICode.scala:82), scala.tools.nsc.backend.icode.GenICode$$ICodePhase$$$$anonfun$$gen$$1.apply(GenICode.scala:82), scala.collection.LinearSeqOptimized$$class.foreach(LinearSeqOptimized.scala:62), scala.collection.immutable.List.foreach(List.scala:46), scala.tools.nsc.backend.icode.GenICode$$ICodePhase.gen(GenICode.scala:82), scala.tools.nsc.backend.icode.GenICode$$ICodePhase.gen(GenICode.scala:92), scala.tools.nsc.backend.icode.GenICode$$ICodePhase.gen(GenICode.scala:78), scala.tools.nsc.backend.icode.GenICode$$ICodePhase.apply(GenICode.scala:74), scala.tools.nsc.Global$$GlobalPhase$$$$anonfun$$applyPhase$$1.apply(Global.scala:272), scala.tools.nsc.Global$$GlobalPhase$$$$anonfun$$applyPhase$$1.apply(Global.scala:272), scala.tools.nsc.reporters.Reporter.withSource(Reporter.scala:49), scala.tools.nsc.Global$$GlobalPhase.applyPhase(Global.scala:272), scala.tools.nsc.Global$$GlobalPhase$$$$anonfun$$run$$1.apply(Global.scala:248), scala.tools.nsc.Global$$GlobalPhase$$$$anonfun$$run$$1.apply(Global.scala:248), scala.collection.Iterator$$class.foreach(Iterator.scala:627), scala.collection.mutable.ListBuffer$$$$anon$$1.foreach(ListBuffer.scala:305), scala.tools.nsc.Global$$GlobalPhase.run(Global.scala:248), scala.tools.nsc.backend.icode.GenICode$$ICodePhase.run(GenICode.scala:67), scala.tools.nsc.Global$$Run.compileSources(Global.scala:729), scala.tools.nsc.Global$$Run.compile(Global.scala:815), scala.tools.nsc.Main$$.process(Main.scala:109), scala.tools.nsc.Main$$.main(Main.scala:123), scala.tools.nsc.Main.main(Main.scala), sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method), sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39), sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25), java.lang.reflect.Method.invoke(Method.java:597), org.jetbrains.plugins.scala.compiler.rt.ScalacRunner.main(ScalacRunner.java:74)]
Error:sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Error:sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
Error:sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
Error:java.lang.reflect.Method.invoke(Method.java:597)
Error:org.jetbrains.plugins.scala.compiler.rt.ScalacRunner.main(ScalacRunner.java:74)
Error:Caused by java.lang.Error: symbol value player$$1 does not exist in de.sciss.synth.Buffer.play
Error:scala.tools.nsc.symtab.SymbolTable.abort(SymbolTable.scala:34)
Error:scala.tools.nsc.backend.icode.GenICode$$ICodePhase.scala$$tools$$nsc$$backend$$icode$$GenICode$$ICodePhase$$$$genLoad(GenICode.scala:844)
Error:scala.tools.nsc.backend.icode.GenICode$$ICodePhase.genLoadArguments(GenICode.scala:1031)
Error:scala.tools.nsc.backend.icode.GenICode$$ICodePhase.scala$$tools$$nsc$$backend$$icode$$GenICode$$ICodePhase$$$$genLoad(GenICode.scala:664)
Error:scala.tools.nsc.backend.icode.GenICode$$ICodePhase.scala$$tools$$nsc$$backend$$icode$$GenICode$$ICodePhase$$$$genLoad(GenICode.scala:878)
Error:scala.tools.nsc.backend.icode.GenICode$$ICodePhase.scala$$tools$$nsc$$backend$$icode$$GenICode$$ICodePhase$$$$genLoad(GenICode.scala:870)
Error:scala.tools.nsc.backend.icode.GenICode$$ICodePhase.scala$$tools$$nsc$$backend$$icode$$GenICode$$ICodePhase$$$$genLoad(GenICode.scala:743)
Error:scala.tools.nsc.backend.icode.GenICode$$ICodePhase.scala$$tools$$nsc$$backend$$icode$$GenICode$$ICodePhase$$$$genLoad(GenICode.scala:513)
Error:scala.tools.nsc.backend.icode.GenICode$$ICodePhase.scala$$tools$$nsc$$backend$$icode$$GenICode$$ICodePhase$$$$genStat(GenICode.scala:184)
Error:scala.tools.nsc.backend.icode.GenICode$$ICodePhase$$$$anonfun$$genStat$$1.apply(GenICode.scala:156)
Error:scala.collection.LinearSeqOptimized$$class.foldLeft(LinearSeqOptimized.scala:124)
Error:scala.collection.immutable.List.foldLeft(List.scala:46)
Error:scala.tools.nsc.backend.icode.GenICode$$ICodePhase.genStat(GenICode.scala:156)
Error:scala.tools.nsc.backend.icode.GenICode$$ICodePhase.scala$$tools$$nsc$$backend$$icode$$GenICode$$ICodePhase$$$$genLoad(GenICode.scala:869)
Error:scala.tools.nsc.backend.icode.GenICode$$ICodePhase.gen(GenICode.scala:127)
Error:scala.tools.nsc.backend.icode.GenICode$$ICodePhase$$$$anonfun$$gen$$1.apply(GenICode.scala:82)
Error:scala.collection.LinearSeqOptimized$$class.foreach(LinearSeqOptimized.scala:62)
Error:scala.collection.immutable.List.foreach(List.scala:46)
Error:scala.tools.nsc.backend.icode.GenICode$$ICodePhase.gen(GenICode.scala:82)
Error:scala.tools.nsc.backend.icode.GenICode$$ICodePhase.gen(GenICode.scala:149)
Error:scala.tools.nsc.backend.icode.GenICode$$ICodePhase.gen(GenICode.scala:101)
Error:scala.tools.nsc.backend.icode.GenICode$$ICodePhase.gen(GenICode.scala:92)
Error:scala.tools.nsc.backend.icode.GenICode$$ICodePhase.gen(GenICode.scala:78)
Error:scala.tools.nsc.backend.icode.GenICode$$ICodePhase.apply(GenICode.scala:74)
Error:scala.tools.nsc.Global$$GlobalPhase$$$$anonfun$$applyPhase$$1.apply(Global.scala:272)
Error:scala.tools.nsc.reporters.Reporter.withSource(Reporter.scala:49)
Error:scala.tools.nsc.Global$$GlobalPhase.applyPhase(Global.scala:272)
Error:scala.tools.nsc.Global$$GlobalPhase$$$$anonfun$$run$$1.apply(Global.scala:248)
Error:scala.collection.Iterator$$class.foreach(Iterator.scala:627)
Error:scala.collection.mutable.ListBuffer$$$$anon$$1.foreach(ListBuffer.scala:305)
Error:scala.tools.nsc.Global$$GlobalPhase.run(Global.scala:248)
Error:scala.tools.nsc.backend.icode.GenICode$$ICodePhase.run(GenICode.scala:67)
Error:scala.tools.nsc.Global$$Run.compileSources(Global.scala:729)
Error:scala.tools.nsc.Global$$Run.compile(Global.scala:815)
Error:scala.tools.nsc.Main$$.process(Main.scala:109)
Error:scala.tools.nsc.Main$$.main(Main.scala:123)
Error:scala.tools.nsc.Main.main(Main.scala)

the project is fairly complex and in this case uses a lot of implicits, so it will be difficult to create an isolated case...

this is with Scala 2.8 RC1.

a workaround has been committed in the next version # aec41adf6a91ad7ecf5b0028bb79359d06b9a3ef , which uses an explicit method for creating the Synth instead:

def play( loop: Boolean = false, amp: Float = 1f, out: Int = 0 ) : Synth = {
      import SC._
      SC.play( server, out ) { // working around nasty compiler bug
         val ply = PlayBuf.ar( numChannels, id, BufRateScale.kr( id ), loop = if( loop ) 1 else 0 )
         if( !loop ) FreeSelfWhenDone.kr( ply )
         ply * amp
      }
   }

this still leaves me with a strange runtime error i will need to examine, though...

sorry for not being able to provide easier cases, but i guess that is the nature of nasty compiler bugs....

scabug commented 14 years ago

Imported From: https://issues.scala-lang.org/browse/SI-3366?orig=1 Reporter: @Sciss

scabug commented 14 years ago

@paulp said: It is in their nature to require some effort to distill into a test case. But I haven't yet seen the one where that couldn't be done. As always, tickets lacking a test case are necessarily of lower priority than the ones which do have one. (See #3363 for an example of what happens when one persists.)

scabug commented 14 years ago

@dubochet said: Before we go further in trying to understand what is going on, could you please confirm that this issue is also reproducible with the latest trunk (or wait for RC2 in a few days and test it on this).

scabug commented 14 years ago

@Sciss said: Yes, sure, I will test again against RC2.

scabug commented 14 years ago

@Sciss said: same behaviour in RC2...

scabug commented 14 years ago

@Sciss said: another occasion where i ran into it today. this throws compiler error:

val x = (SynthDef("deepsea" ) {
    val out = "out".kr
    val pan = "pan".kr
    val amp = "amp".kr(0.1)
    val variation = "variation".kr(0.9)
    val n = Rand(7, 46);
    var dt = 25.0 + Rand(-1.7, 1.7);
    dt = dt + LFNoise2.kr(2)* variation * 0.001;
    val freq = 901 + Rand(0, 65);
    val t = Impulse.ar(dt.reciprocal)* 100
    val count = PulseCount.ar(t);
    val mul = count < n;
    var u = BPF.ar(mul * t, freq, 0.1);
    u = BPF.ar(u, freq * (count % LFNoise1.kr(1).madd(9,11) + 1), 0.2);
    DetectSilence.ar(u, doneAction = 2);
    Out.ar(out, Pan2.ar(u, pan, amp * 10));
}).play(s)

this does ok:

val x = (SynthDef("deepsea" ) {
    val out = "out".kr
    val pan = "pan".kr
    val amp = "amp".kr(0.1)
    val variation = "variation".kr(0.9)
    val n = Rand(7, 46);
    var dt = 25.0 + Rand(-1.7, 1.7);
    dt = dt + LFNoise2.kr(2)* variation * 0.001;
    val freq = 901 + Rand(0, 65);
    val t = Impulse.ar(dt.reciprocal)* 100
    val count = PulseCount.ar(t);
    val mul = count < n;
    var u = BPF.ar(mul * t, freq, 0.1);
    u = BPF.ar(u, freq * (count % LFNoise1.kr(1).madd(9,11) + 1), 0.2);
    DetectSilence.ar(u, doneAction = 2);
    Out.ar(out, Pan2.ar(u, pan, amp * 10));
}); x.play(s)
Exception in thread "AWT-EventQueue-0" java.lang.Error: symbol value out$$1 does not exist in line4$$object$$$$iw$$$$iw$$$$iw$$$$iw$$$$iw$$$$iw$$$$iw$$$$iw$$$$iw$$$$iw$$$$iw$$$$iw.<init>
    at scala.tools.nsc.symtab.SymbolTable.abort(SymbolTable.scala:34)
    at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.scala$$tools$$nsc$$backend$$icode$$GenICode$$ICodePhase$$$$genLoad(GenICode.scala:844)
    at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.genLoadArguments(GenICode.scala:1031)
    at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.scala$$tools$$nsc$$backend$$icode$$GenICode$$ICodePhase$$$$genLoad(GenICode.scala:664)
    at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.scala$$tools$$nsc$$backend$$icode$$GenICode$$ICodePhase$$$$genLoad(GenICode.scala:878)
    at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.scala$$tools$$nsc$$backend$$icode$$GenICode$$ICodePhase$$$$genLoad(GenICode.scala:870)
    at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.genLoadArguments(GenICode.scala:1031)
    at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.scala$$tools$$nsc$$backend$$icode$$GenICode$$ICodePhase$$$$genLoad(GenICode.scala:743)
    at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.scala$$tools$$nsc$$backend$$icode$$GenICode$$ICodePhase$$$$genLoad(GenICode.scala:513)
    at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.scala$$tools$$nsc$$backend$$icode$$GenICode$$ICodePhase$$$$genStat(GenICode.scala:184)
    at scala.tools.nsc.backend.icode.GenICode$$ICodePhase$$$$anonfun$$genStat$$1.apply(GenICode.scala:156)
    at scala.tools.nsc.backend.icode.GenICode$$ICodePhase$$$$anonfun$$genStat$$1.apply(GenICode.scala:156)
    at scala.collection.LinearSeqOptimized$$class.foldLeft(LinearSeqOptimized.scala:124)
    at scala.collection.immutable.List.foldLeft(List.scala:46)
    at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.genStat(GenICode.scala:156)
    at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.scala$$tools$$nsc$$backend$$icode$$GenICode$$ICodePhase$$$$genLoad(GenICode.scala:869)
    at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.scala$$tools$$nsc$$backend$$icode$$GenICode$$ICodePhase$$$$genStat(GenICode.scala:173)
    at scala.tools.nsc.backend.icode.GenICode$$ICodePhase$$$$anonfun$$genStat$$1.apply(GenICode.scala:156)
    at scala.tools.nsc.backend.icode.GenICode$$ICodePhase$$$$anonfun$$genStat$$1.apply(GenICode.scala:156)
    at scala.collection.LinearSeqOptimized$$class.foldLeft(LinearSeqOptimized.scala:124)
    at scala.collection.immutable.List.foldLeft(List.scala:46)
    at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.genStat(GenICode.scala:156)
    at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.scala$$tools$$nsc$$backend$$icode$$GenICode$$ICodePhase$$$$genLoad(GenICode.scala:869)
    at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.gen(GenICode.scala:127)
    at scala.tools.nsc.backend.icode.GenICode$$ICodePhase$$$$anonfun$$gen$$1.apply(GenICode.scala:82)
    at scala.tools.nsc.backend.icode.GenICode$$ICodePhase$$$$anonfun$$gen$$1.apply(GenICode.scala:82)
    at scala.collection.LinearSeqOptimized$$class.foreach(LinearSeqOptimized.scala:62)
    at scala.collection.immutable.List.foreach(List.scala:46)
    at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.gen(GenICode.scala:82)
    at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.gen(GenICode.scala:149)
    at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.gen(GenICode.scala:101)
    at scala.tools.nsc.backend.icode.GenICode$$ICodePhase$$$$anonfun$$gen$$1.apply(GenICode.scala
   ... (etc)

again sorry for not being able to provide an isolated example. the above codes can be executed in the REPL fo scalacollider-swing though ( http://github.com/Sciss/ScalaColliderSwing )

scabug commented 14 years ago

@Sciss said: shortened

val x = (SynthDef("deepsea") {
   val out = "out".kr
   Out.ar(out, Silent.ar(2))
}).play(s)
scabug commented 14 years ago

@magarciaEPFL said:

The last snippet was "shortened", what about "self-contained"?

scabug commented 14 years ago

@Sciss said: the library currently doesn't compile against RC3 (due to the @ _* issue). i can try to narrow it down with RC4...

scabug commented 14 years ago

@Sciss said: the problem is still there in RC5. strangely, it doesn't occur with overloaded methods:

val x = (SynthDef("X") {
   val freq = 333
   Out.ar( 0, SinOsc.ar( freq ))
}).play( s.defaultGroup )

this one fails with

java.lang.Error: symbol value freq$$1 does not exist in line30$$object$$$$iw$$$$iw$$$$iw$$$$iw$$$$iw$$$$iw$$$$iw$$$$iw$$$$iw$$$$iw$$$$iw$$$$iw$$$$iw$$$$iw$$$$iw$$$$iw.<init>
    at scala.tools.nsc.symtab.SymbolTable.abort(SymbolTable.scala:33)
    at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.scala$$tools$$nsc$$backend$$icode$$GenICode$$ICodePhase$$$$genLoad(GenICode.scala:843)
    at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.genLoadArguments(GenICode.scala:1030)
    at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.scala$$tools$$nsc$$backend$$icode$$GenICode$$ICodePhase$$$$genLoad(GenICode.scala:663)
    at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.scala$$tools$$nsc$$backend$$icode$$GenICode$$ICodePhase$$$$genLoad(GenICode.scala:877)
    at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.scala$$tools$$nsc$$backend$$icode$$GenICode$$ICodePhase$$$$genLoad(GenICode.scala:869)

but this one:

val x = (SynthDef("X") {
   val freq = 333
   Out.ar( 0, SinOsc.ar( freq ))
}).play

has no problems. the respective methods in SynthDef are:

def play: Synth = play()
def play( target: Node = Server.default, args: Seq[ ControlSetMap ] = Nil, addAction: AddAction = addToHead ) : Synth = { ... }

trying to isolate this, but it's difficult...