Aladdin - Scala Bugtracking
[#1082] project: compiler priority: low category: bug
submitter assigned to status date submitted
Nikolay Adriaan fixed 2007-05-03 08:39:50.0
subject [contrib #452] Explicit self alias with wrong access crashes compiler
code
Crashes compiler:

trait Foo { self =>
  self.m 
}

Compiles:

trait Foo { self =>
  def m {}
  self.m 
}

Doesn't crash:

trait Foo { self =>
  m 
}

what happened
scala> trait Foo { self => self.m }
Exception in thread "main" java.util.NoSuchElementException: None.get
        at scala.None$.get(Option.scala:137)
        at scala.None$.get(Option.scala:135)
        at scala.tools.nsc.typechecker.Typers$Typer.typedSelect$0(Typers.scala:2174)
        at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:2580)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:2641)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:2674)
        at scala.tools.nsc.typechecker.Typers$Typer.typedStat$0(Typers.scala:1396)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$58.apply(Typers.scala:1426)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$58.apply(Typers.scala:1426)
        at scala.List$.loop$0(List.scala:243)
        at scala.List$.mapConserve(List.scala:260)
        at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:1426)
        at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:1056)
        at scala.tools.nsc.typechecker.Typers$Typer.typedClassDef(Typers.scala:951)
        at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:2406)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:2641)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:2674)
        at scala.tools.nsc.typechecker.Typers$Typer.typedStat$0(Typers.scala:1396)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$58.apply(Typers.scala:1426)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$58.apply(Typers.scala:1426)
        at scala.List$.loop$0(List.scala:243)
        at scala.List$.mapConserve(List.scala:260)
        at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:1426)
        at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:1056)
        at scala.tools.nsc.typechecker.Typers$Typer.typedModuleDef(Typers.scala:967)
        at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:2409)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:2641)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:2674)
        at scala.tools.nsc.typechecker.Typers$Typer.typedStat$0(Typers.scala:1396)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$58.apply(Typers.scala:1426)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$58.apply(Typers.scala:1426)
        at scala.List$.loop$0(List.scala:243)
        at scala.List$.mapConserve(List.scala:260)
        at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:1426)
        at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:1056)
        at scala.tools.nsc.typechecker.Typers$Typer.typedModuleDef(Typers.scala:967)
        at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:2409)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:2641)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:2674)
        at scala.tools.nsc.typechecker.Typers$Typer.typedStat$0(Typers.scala:1396)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$58.apply(Typers.scala:1426)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$58.apply(Typers.scala:1426)
        at scala.List$.loop$0(List.scala:243)
        at scala.List$.mapConserve(List.scala:260)
        at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:1426)
        at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:1056)
        at scala.tools.nsc.typechecker.Typers$Typer.typedModuleDef(Typers.scala:967)
        at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:2409)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:2641)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:2674)
        at scala.tools.nsc.typechecker.Typers$Typer.typedStat$0(Typers.scala:1396)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$58.apply(Typers.scala:1426)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$58.apply(Typers.scala:1426)
        at scala.List$.loop$0(List.scala:243)
        at scala.List$.mapConserve(List.scala:260)
        at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:1426)
        at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:2402)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:2641)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:2674)
        at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$1.apply(Analyzer.scala:38)
        at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:241)
        at scala.tools.nsc.Global$GlobalPhase$$anonfun$2.apply(Global.scala:230)
        at scala.tools.nsc.Global$GlobalPhase$$anonfun$2.apply(Global.scala:230)
        at scala.Iterator$class.foreach(Iterator.scala:369)
        at scala.collection.mutable.ListBuffer$$anon$0.foreach(ListBuffer.scala:245)
        at scala.tools.nsc.Global$GlobalPhase.run(Global.scala:230)
        at scala.tools.nsc.Global$Run.compileSources(Global.scala:498)
        at scala.tools.nsc.Interpreter$Request.compile(Interpreter.scala:669)
        at scala.tools.nsc.Interpreter.interpret(Interpreter.scala:433)
        at scala.tools.nsc.InterpreterLoop.interpretStartingWith(InterpreterLoop.scala:236)
        at scala.tools.nsc.InterpreterLoop.command(InterpreterLoop.scala:223)
        at scala.tools.nsc.InterpreterLoop.repl(InterpreterLoop.scala:136)
        at scala.tools.nsc.InterpreterLoop.main(InterpreterLoop.scala:271)
        at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:92)
        at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
what expected Compiler does not crash but emits error message
[back to overview]
Changes of this bug report
Nikolay  edited on  2007-05-03 08:40:44.0
contribution #452
Adriaan  edited on  2007-05-03 09:28:47.0
quick fix: using for comprehension instead of optimistic get
(if (!inIDE && (context.unit ne null) && (qual.pos).line.get <
                     tree.pos.line.get)
became
(if (!inIDE && (context.unit ne null) && ((for(a <- qual.pos.line; 
                     b <- tree.pos.line) yield a < b).getOrElse(false)))