Skip to content

Compiler exception in innocent code. #2175

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

Closed
scabug opened this issue Jul 21, 2009 · 7 comments
Closed

Compiler exception in innocent code. #2175

scabug opened this issue Jul 21, 2009 · 7 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Jul 21, 2009

In trunk:

case class Property[T](private var t: T) {
 var beforeChanges: List[(T, T) => Unit] = Nil
 var afterChanges: List[T => Unit] = Nil
 def apply = t
 def update(t2: T) = {
  beforeChanges foreach (_(t, t2))
  t = t2
  afterChanges foreach (_(t2))
 }
}

causes:

Exception in thread "main" java.lang.Error: symbol value t$$1$$1 does not exist in line3$$object$$$$iw$$$$iw$$Property.equals
        at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.scala$$tools$$nsc$$backend$$icode$$GenICode$$ICodePhase$$$$genLoad(GenICode.scala:918)
        at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.genLoadArguments(GenICode.scala:1109)
        at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.scala$$tools$$nsc$$backend$$icode$$GenICode$$ICodePhase$$$$genLoad(GenICode.scala:826)
        at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.genCond(GenICode.scala:1401)
        at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.scala$$tools$$nsc$$backend$$icode$$GenICode$$ICodePhase$$$$genLoad(GenICode.scala:432)
        at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.scala$$tools$$nsc$$backend$$icode$$GenICode$$ICodePhase$$$$genLoad(GenICode.scala:945)
        at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.scala$$tools$$nsc$$backend$$icode$$GenICode$$ICodePhase$$$$genLoad(GenICode.scala:945)
        at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.scala$$tools$$nsc$$backend$$icode$$GenICode$$ICodePhase$$$$genLoad(GenICode.scala:945)
        at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.scala$$tools$$nsc$$backend$$icode$$GenICode$$ICodePhase$$$$genLoad(GenICode.scala:455)
        at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.scala$$tools$$nsc$$backend$$icode$$GenICode$$ICodePhase$$$$genLoad(GenICode.scala:945)
        at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.scala$$tools$$nsc$$backend$$icode$$GenICode$$ICodePhase$$$$genLoad(GenICode.scala:945)
        at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.genCond(GenICode.scala:1401)
        at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.scala$$tools$$nsc$$backend$$icode$$GenICode$$ICodePhase$$$$genLoad(GenICode.scala:764)
        at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.gen(GenICode.scala:114)
        at scala.tools.nsc.backend.icode.GenICode$$ICodePhase$$$$anonfun$$gen$$1.apply(GenICode.scala:71)
        at scala.tools.nsc.backend.icode.GenICode$$ICodePhase$$$$anonfun$$gen$$1.apply(GenICode.scala:71)
        at scala.collection.generic.LinearSequenceTemplate$$class.foreach(LinearSequenceTemplate.scala:81)
        at scala.collection.immutable.List.foreach(List.scala:26)
        at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.gen(GenICode.scala:71)
        at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.gen(GenICode.scala:136)
        at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.gen(GenICode.scala:90)
        at scala.tools.nsc.backend.icode.GenICode$$ICodePhase$$$$anonfun$$gen$$1.apply(GenICode.scala:71)
        at scala.tools.nsc.backend.icode.GenICode$$ICodePhase$$$$anonfun$$gen$$1.apply(GenICode.scala:71)
        at scala.collection.generic.LinearSequenceTemplate$$class.foreach(LinearSequenceTemplate.scala:81)
        at scala.collection.immutable.List.foreach(List.scala:26)
        at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.gen(GenICode.scala:71)
        at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.gen(GenICode.scala:81)
        at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.gen(GenICode.scala:67)
        at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.apply(GenICode.scala:63)
        at scala.tools.nsc.Global$$GlobalPhase.applyPhase(Global.scala:311)
        at scala.tools.nsc.Global$$GlobalPhase$$$$anonfun$$run$$1.apply(Global.scala:289)
        at scala.tools.nsc.Global$$GlobalPhase$$$$anonfun$$run$$1.apply(Global.scala:289)
        at scala.collection.Iterator$$class.foreach(Iterator.scala:500)
        at scala.collection.mutable.ListBuffer$$$$anon$$1.foreach(ListBuffer.scala:280)
        at scala.tools.nsc.Global$$GlobalPhase.run(Global.scala:289)
        at scala.tools.nsc.backend.icode.GenICode$$ICodePhase.run(GenICode.scala:56)
        at scala.tools.nsc.Global$$Run.compileSources(Global.scala:787)
        at scala.tools.nsc.Interpreter$$Request.compile(Interpreter.scala:712)
        at scala.tools.nsc.Interpreter.interpret(Interpreter.scala:426)
        at scala.tools.nsc.InterpreterLoop.interpretStartingWith(InterpreterLoop.scala:329)
        at scala.tools.nsc.InterpreterLoop.interpretStartingWith(InterpreterLoop.scala:339)
        at scala.tools.nsc.InterpreterLoop.interpretStartingWith(InterpreterLoop.scala:339)
        at scala.tools.nsc.InterpreterLoop.interpretStartingWith(InterpreterLoop.scala:339)
        at scala.tools.nsc.InterpreterLoop.interpretStartingWith(InterpreterLoop.scala:339)
        at scala.tools.nsc.InterpreterLoop.interpretStartingWith(InterpreterLoop.scala:339)
        at scala.tools.nsc.InterpreterLoop.interpretStartingWith(InterpreterLoop.scala:339)
        at scala.tools.nsc.InterpreterLoop.interpretStartingWith(InterpreterLoop.scala:339)
        at scala.tools.nsc.InterpreterLoop.interpretStartingWith(InterpreterLoop.scala:339)
        at scala.tools.nsc.InterpreterLoop.interpretStartingWith(InterpreterLoop.scala:339)
        at scala.tools.nsc.InterpreterLoop.command(InterpreterLoop.scala:306)
        at scala.tools.nsc.InterpreterLoop.processLine$$1(InterpreterLoop.scala:203)
        at scala.tools.nsc.InterpreterLoop.repl(InterpreterLoop.scala:221)
        at scala.tools.nsc.InterpreterLoop.main(InterpreterLoop.scala:377)
        at scala.tools.nsc.MainGenericRunner$$.main(MainGenericRunner.scala:126)
        at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
@scabug
Copy link
Author

scabug commented Jul 21, 2009

Imported From: https://issues.scala-lang.org/browse/SI-2175?orig=1
Reporter: Ricky Clarkson (ricky_clarkson)

@scabug
Copy link
Author

scabug commented Jul 21, 2009

@lrytz said:
can you have a look at it and find out what part of the compiler is causing it?

@scabug
Copy link
Author

scabug commented Aug 10, 2009

@TiarkRompf said:
sorry, I'm swamped with exam stuff at the moment. Iuli, can you have a look?

@scabug
Copy link
Author

scabug commented Aug 19, 2009

@dragos said:
This is a bug in the pattern matcher. It generates a reference to a synthetic local val which is not defined.

@scabug
Copy link
Author

scabug commented Aug 19, 2009

@paulp said:
Replying to [comment:5 dragos]:

This is a bug in the pattern matcher. It generates a reference to a synthetic local val which is not defined.

I think this is another variation on the many bugs which swirl around private in case classes. Some I have hacked around unpleasantly, some are still outstanding (especially when you kick it up a notch to private[this]) and I'm not at all sure they can be dealt with sanely.

I really wonder why someone would want "private var" as a case class field anyway... I would like to propose off the cuff that neither "private" nor "var" be allowed in the first parameter list to a case class. Put anything you want in the second. OK, so multiple parameter lists to case classes are totally broken right now, but if fixed that would offer some measure of sanity.

Not that this doesn't still need to be fixed, but I'm afraid it will end up being another ugly band-aid around the dancing privates.

FWIW neither of these crashes:

case class Property[T]()(private var t: Int)
case class Property[T](var t: Int)

@scabug
Copy link
Author

scabug commented Aug 19, 2009

Ricky Clarkson (ricky_clarkson) said:
Though I'm the reporter I'd agree that Scala probably shouldn't support this. The code dates from a time when I was 'case class happy'. I wouldn't use private or var with case classes today.

@scabug
Copy link
Author

scabug commented Oct 6, 2009

@paulp said:
Couldn't tell you when this domino fell, but fall it did. Test case in r18927.

@scabug scabug closed this as completed May 18, 2011
@scabug scabug added this to the 2.8.0 milestone Apr 7, 2017
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

No branches or pull requests

2 participants