Compiler crashes instead of reporting an error

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Compiler crashes instead of reporting an error

Georgi Jojgov
Hi,

The code below crashes the 2.11.8 compiler instead of producing a type mismatch error message (see attachments):

object Crasher {
  trait
Handler {
   
def onPush(): Unit
   
def onUpstreamFinish() : Unit
 
}

 
def setHandler(handler: Handler): Unit = {}

  setHandler
(new Handler {
   
override def onPush(): Unit = {
     
// changing 100L to 100 avoids the crash
     
(0 until 100L) foreach {_ => ()}
   
}


   
@throws(classOf[Exception])
   
def onUpstreamFinish(): Unit = {}
 
})
}

The top of error stack trace is:

java.lang.NullPointerException
 at scala
.tools.nsc.typechecker.Typers$Typer.typedAnnotation(Typers.scala:3669)
 at scala
.tools.nsc.typechecker.Namers$Namer$$anonfun$23$$anonfun$apply$17$$anonfun$apply$18.apply(Namers.scala:1504)
 at scala
.tools.nsc.typechecker.Namers$Namer$$anonfun$23$$anonfun$apply$17$$anonfun$apply$18.apply(Namers.scala:1504)
 at scala
.reflect.internal.SymbolTable.enteringPhase(SymbolTable.scala:235)
 at scala
.tools.nsc.typechecker.Namers$Namer$$anonfun$23$$anonfun$apply$17.apply(Namers.scala:1504)
 at scala
.tools.nsc.typechecker.Namers$Namer$$anonfun$23$$anonfun$apply$17.apply(Namers.scala:1504)
 at scala
.reflect.internal.AnnotationInfos$LazyAnnotationInfo.forcedInfo$lzycompute(AnnotationInfos.scala:212)
 at scala
.reflect.internal.AnnotationInfos$LazyAnnotationInfo.forcedInfo(AnnotationInfos.scala:212)
 at scala
.reflect.internal.AnnotationInfos$LazyAnnotationInfo.completeInfo(AnnotationInfos.scala:225)
 at scala
.tools.nsc.typechecker.Typers$Typer$$anonfun$typedDefDef$2.apply(Typers.scala:2185)
 at scala
.tools.nsc.typechecker.Typers$Typer$$anonfun$typedDefDef$2.apply(Typers.scala:2185)
 at scala
.collection.immutable.List.map(List.scala:273)
 at scala
.tools.nsc.typechecker.Typers$Typer.typedDefDef(Typers.scala:2185)
 at scala
.tools.nsc.typechecker.Typers$Typer.typedMemberDef$1(Typers.scala:5308)
 at scala
.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5359)
 at scala
.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5396)
 at scala
.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedInternal(Typers.scala:5423)
 at scala
.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5370)
 at scala
.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5374)
 at scala
.tools.nsc.typechecker.Typers$Typer.typedByValueExpr(Typers.scala:5452)
 at scala
.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedStat$1(Typers.scala:3047)
 at scala
.tools.nsc.typechecker.Typers$Typer$$anonfun$65.apply(Typers.scala:3151)
 at scala
.tools.nsc.typechecker.Typers$Typer$$anonfun$65.apply(Typers.scala:3151)


The expected compile error is exposed for example by commenting out the @throws annotation:

[error] <....>/Crasher.scala:12: type mismatch;
[error]  found   : Long(100L)
[error]  required: Int
[error]       (0 until 100L) foreach {_ => ()}
[error]                ^
[error] one error found

Removing the error by changing 

(0 until 100L) foreach {_ => ()}

to

(0 until 100) foreach {_ => ()}

results in successful compile.


Is this a known issue or should I file a bug?

Georgi




--
You received this message because you are subscribed to the Google Groups "scala-internals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

bug_report.zip (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Compiler crashes instead of reporting an error

Seth Tisue-3
The 2.12.0 compiler doesn’t crash on this, so I wouldn’t bother opening a JIRA ticket on it.

--
You received this message because you are subscribed to the Google Groups "scala-internals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.