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

Compiler exception instead of forward reference error with nested case class #5390

Closed
scabug opened this issue Jan 19, 2012 · 3 comments
Closed
Assignees
Milestone

Comments

@scabug
Copy link

@scabug scabug commented Jan 19, 2012

With scala-2.10.0.rdev-4208-2012-01-19-g58cb15c, compiling:

// Test.scala
class A {
  case class B(s: String)
}


object X {
  def foo {
    val b = a.B("foo")
    val a = new A
  }
}

Gives a compiler stack trace:

error: symbol value a does not exist in X.foo
error: scala.reflect.internal.FatalError: symbol value a does not exist in X.foo
	at scala.reflect.internal.SymbolTable.abort(SymbolTable.scala:36)
	at scala.tools.nsc.Global.abort(Global.scala:170)
	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genLoad(GenICode.scala:996)
	at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$genLoadArguments$1.apply(GenICode.scala:1190)
	at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$genLoadArguments$1.apply(GenICode.scala:1188)
	at scala.collection.LinearSeqOptimized$class.foldLeft(LinearSeqOptimized.scala:111)
	at scala.collection.immutable.List.foldLeft(List.scala:76)
	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.genLoadArguments(GenICode.scala:1188)
	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genLoad(GenICode.scala:812)
	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genLoad(GenICode.scala:641)
	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genStat(GenICode.scala:178)
	at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$genStat$1.apply(GenICode.scala:147)
	at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$genStat$1.apply(GenICode.scala:147)
	at scala.collection.LinearSeqOptimized$class.foldLeft(LinearSeqOptimized.scala:111)
	at scala.collection.immutable.List.foldLeft(List.scala:76)
	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genLoad(GenICode.scala:1021)
	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:115)
	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.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
	at scala.collection.immutable.List.foreach(List.scala:76)
	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:71)
	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:140)
	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.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
	at scala.collection.immutable.List.foreach(List.scala:76)
	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:386)
	at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:355)
	at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:349)
	at scala.collection.Iterator$class.foreach(Iterator.scala:687)
	at scala.collection.AbstractIterator.foreach(Iterator.scala:1112)
	at scala.tools.nsc.Global$GlobalPhase.run(Global.scala:349)
	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.run(GenICode.scala:56)
	at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1130)
	at scala.tools.nsc.Global$Run.compileSources(Global.scala:1105)
	at scala.tools.nsc.Global$Run.compile(Global.scala:1227)
	at scala.tools.nsc.Driver.doCompile(Driver.scala:31)
	at scala.tools.nsc.Main$.doCompile(Main.scala:81)
	at scala.tools.nsc.Driver.process(Driver.scala:52)
	at scala.tools.nsc.Driver.main(Driver.scala:65)
	at scala.tools.nsc.Main.main(Main.scala)

It should say something like, "forward reference extends over definition of value b".

@scabug
Copy link
Author

@scabug scabug commented Jan 19, 2012

Imported From: https://issues.scala-lang.org/browse/SI-5390?orig=1
Reporter: Matt Russell (mattrussell)
Affected Versions: 2.8.1, 2.9.2, 2.10.0

@scabug
Copy link
Author

@scabug scabug commented Feb 7, 2012

@adriaanm said:
Chris, could you please take a look? There should indeed be an error before this gets to genicode. One of the relevant methods is probably enterReference in RefChecks.

@scabug
Copy link
Author

@scabug scabug commented Dec 17, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants