NoSuchElementException during twirl compilation
jlupien opened this issue · comments
Jeff Lupien commented
There's a bug that existed in Play where the template compiler throws a NoSuchElement exception when trying to access the left projection of an Either$RightProjection. A fix was pulled into Play 2.0, and I'd like to port it to twirl.
The stack trace looks like this:
java.util.NoSuchElementException: Either.left.value on Right
at scala.Either$LeftProjection.get(Either.scala:287)
at twirl.compiler.TwirlCompiler$TemplateAsFunctionCompiler$TreeCreationMethods$class.treeFrom(TwirlCompiler.scala:638)
at twirl.compiler.TwirlCompiler$TemplateAsFunctionCompiler$PresentationCompiler$.treeFrom(TwirlCompiler.scala:645)
at twirl.compiler.TwirlCompiler$TemplateAsFunctionCompiler$TreeCreationMethods$class.treeFrom(TwirlCompiler.scala:623)
at twirl.compiler.TwirlCompiler$TemplateAsFunctionCompiler$PresentationCompiler$.treeFrom(TwirlCompiler.scala:645)
at twirl.compiler.TwirlCompiler$TemplateAsFunctionCompiler$.getFunctionMapping(TwirlCompiler.scala:549)
at twirl.compiler.TwirlCompiler$.generateFinalTemplate(TwirlCompiler.scala:488)
at twirl.compiler.TwirlCompiler$.compile(TwirlCompiler.scala:186)
at twirl.sbt.TemplateCompiler$$anonfun$compile$3.apply(TemplateCompiler.scala:46)
at twirl.sbt.TemplateCompiler$$anonfun$compile$3.apply(TemplateCompiler.scala:44)
at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:60)
at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:47)
at twirl.sbt.TemplateCompiler$.compile(TemplateCompiler.scala:44)
at twirl.sbt.TwirlPlugin$Twirl$$anonfun$settings$4.apply(TwirlPlugin.scala:50)
at twirl.sbt.TwirlPlugin$Twirl$$anonfun$settings$4.apply(TwirlPlugin.scala:50)
etc
References:
Play 2.0 bug report - for some reason it was never resolved
Play 2.0 github pull request - this has a fix
[Google Search](scala.tools.nsc.interactive.FreshRunReq play) - many reports of the same issue
Jeff Lupien commented
The fix is in our fork at commit 63ba035. We tested locally.
Johannes Rudolph commented
Fixed as part of #16 and released in 0.7.0.