Skip to content

Conversation

noti0na1
Copy link
Member

@noti0na1 noti0na1 commented Jun 9, 2020

Compiler will crash when file path is invalid and throw NullPointerException, which doesn't contain any useful information.

Example:

sbt:dotty> dotc Xprint:all

Before fix:

java.lang.NullPointerException while compiling Xprint:all
Exception in thread "main" java.lang.NullPointerException
        at dotty.tools.dotc.printing.Formatting$StringFormatter.showArg(Formatting.scala:39)
        at dotty.tools.dotc.printing.Formatting$StringFormatter.treatArg(Formatting.scala:49)
        at dotty.tools.dotc.printing.Formatting$StringFormatter.$anonfun$2(Formatting.scala:62)
        at scala.collection.LazyZip2$$anon$1$$anon$2.next(LazyZipOps.scala:42)
        at scala.collection.mutable.Growable.addAll(Growable.scala:62)
        at scala.collection.mutable.Growable.addAll$(Growable.scala:59)
        at scala.collection.mutable.ArrayBuilder.addAll(ArrayBuilder.scala:69)
        at scala.collection.IterableOnceOps.toArray(IterableOnce.scala:1289)
        at scala.collection.IterableOnceOps.toArray$(IterableOnce.scala:1283)
        at scala.collection.AbstractIterable.toArray(Iterable.scala:920)
        at scala.Array$.from(Array.scala:59)
        at scala.collection.immutable.ArraySeq$.from(ArraySeq.scala:180)
        at scala.collection.immutable.ArraySeq$.from(ArraySeq.scala:171)
        at scala.collection.ClassTagIterableFactory$AnyIterableDelegate.from(Factory.scala:656)
        at scala.collection.BuildFromLowPriority2$$anon$11.fromSpecific(BuildFrom.scala:112)
        at scala.collection.BuildFromLowPriority2$$anon$11.fromSpecific(BuildFrom.scala:109)
        at scala.collection.LazyZip2.map(LazyZipOps.scala:37)
        at dotty.tools.dotc.printing.Formatting$StringFormatter.assemble(Formatting.scala:62)
        at dotty.tools.dotc.core.Decorators$StringInterpolators$.i$extension(Decorators.scala:215)
        at dotty.tools.dotc.Run.compile$$anonfun$1(Run.scala:114)
        at dotty.tools.dotc.reporting.NoExplanation.msg(Message.scala:122)
        at dotty.tools.dotc.reporting.Message.message(Message.scala:80)
        at dotty.tools.dotc.reporting.Message.isNonSensical(Message.scala:92)
        at dotty.tools.dotc.reporting.HideNonSensicalMessages.isHidden(HideNonSensicalMessages.scala:16)
        at dotty.tools.dotc.reporting.AbstractReporter.isHidden(AbstractReporter.scala:8)
        at dotty.tools.dotc.reporting.Reporter.report(Reporter.scala:265)
        at dotty.tools.dotc.reporting.Reporting.echo(Reporter.scala:78)
        at dotty.tools.dotc.core.Contexts$Context.echo(Contexts.scala:78)
        at dotty.tools.dotc.Run.compile(Run.scala:114)
        at dotty.tools.dotc.Driver.doCompile(Driver.scala:38)
        at dotty.tools.dotc.Driver.process(Driver.scala:194)
        at dotty.tools.dotc.Driver.process(Driver.scala:163)
        at dotty.tools.dotc.Driver.process(Driver.scala:175)
        at dotty.tools.dotc.Driver.main(Driver.scala:202)
        at dotty.tools.dotc.Main.main(Main.scala)

After fix:

invalid file path: Illegal char <:> at index 6: Xprint:all
1 error found

@noti0na1 noti0na1 merged commit defcea3 into scala:master Jun 9, 2020
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

Successfully merging this pull request may close these issues.

2 participants