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

"-Ywarn-unused-import" + macro = crash #9839

Closed
scabug opened this Issue Jun 30, 2016 · 2 comments

Comments

Projects
None yet
3 participants
@scabug
Copy link

scabug commented Jun 30, 2016

build.sbt

scalacOptions += "-Ywarn-unused-import"

libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value

scalaVersion := "2.11.8"

Macro.scala

package com.example

import scala.reflect.macros.blackbox.Context
import scala.language.experimental.macros

object Macro {
  def foo: Int = macro fooImpl
  def fooImpl(c: Context): c.Tree = {
    import c.universe._

    q"""
     import scala.util.Random
     42
    """
  }
}

REPL

Welcome to Scala 2.11.8 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_92).
Type in expressions for evaluation. Or try :help.

scala> com.example.Macro.foo
java.lang.ArrayIndexOutOfBoundsException: 182
        at scala.reflect.internal.util.InternalPositionImpl$class.calculateColumn(Position.scala:211)
        at scala.reflect.internal.util.InternalPositionImpl$class.column(Position.scala:167)
        at scala.reflect.internal.util.Position.column(Position.scala:12)
        at scala.reflect.internal.util.InternalPositionImpl$class.lineCaret(Position.scala:169)
        at scala.reflect.internal.util.Position.lineCaret(Position.scala:12)
        at scala.reflect.internal.util.InternalPositionImpl$class.indicator$1(Position.scala:186)
        at scala.reflect.internal.util.InternalPositionImpl$class.errorAt$1(Position.scala:187)
        at scala.reflect.internal.util.InternalPositionImpl$class.showError(Position.scala:192)
        at scala.reflect.internal.util.Position.showError(Position.scala:12)
        at scala.reflect.internal.util.Position$.formatMessage(Position.scala:42)
        at scala.tools.nsc.reporters.ConsoleReporter.printMessage(ConsoleReporter.scala:50)
        at scala.tools.nsc.interpreter.ReplReporter.print(ReplReporter.scala:50)
        at scala.tools.nsc.reporters.ConsoleReporter.display(ConsoleReporter.scala:69)
        at scala.tools.nsc.reporters.AbstractReporter.info0(AbstractReporter.scala:48)
        at scala.tools.nsc.reporters.AbstractReporter.info0(AbstractReporter.scala:16)
        at scala.reflect.internal.Reporter.warning(Reporting.scala:81)
        at scala.tools.nsc.interpreter.ReplReporter.scala$tools$nsc$interpreter$ReplReporter$$super$warning(ReplReporter.scala:32)
        at scala.tools.nsc.interpreter.ReplReporter$$anonfun$warning$1.apply(ReplReporter.scala:32)
        at scala.tools.nsc.interpreter.ReplReporter$$anonfun$warning$1.apply(ReplReporter.scala:32)
        at scala.tools.nsc.interpreter.ReplReporter.withoutTruncating(ReplReporter.scala:28)
        at scala.tools.nsc.interpreter.ReplReporter.warning(ReplReporter.scala:32)
        at scala.tools.nsc.typechecker.Contexts$class.warnUnusedImports(Contexts.scala:64)
        at scala.tools.nsc.interpreter.ReplGlobal$$anon$1.warnUnusedImports(ReplGlobal.scala:23)
        at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.apply(Analyzer.scala:106)
        at scala.tools.nsc.Global$GlobalPhase$$anonfun$applyPhase$1.apply$mcV$sp(Global.scala:440)
        at scala.tools.nsc.Global$GlobalPhase.withCurrentUnit(Global.scala:431)
        at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:440)
        at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3$$anonfun$run$1.apply(Analyzer.scala:94)
        at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3$$anonfun$run$1.apply(Analyzer.scala:93)
        at scala.collection.Iterator$class.foreach(Iterator.scala:893)
        at scala.collection.AbstractIterator.foreach(Iterator.scala:1336)
        at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.run(Analyzer.scala:93)
        at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1501)
        at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1486)
        at scala.tools.nsc.Global$Run.compileSources(Global.scala:1481)
        at scala.tools.nsc.interpreter.IMain.compileSourcesKeepingRun(IMain.scala:435)
        at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.compileAndSaveRun(IMain.scala:855)
        at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.compile(IMain.scala:813)
        at scala.tools.nsc.interpreter.IMain$Request.compile$lzycompute(IMain.scala:1002)
        at scala.tools.nsc.interpreter.IMain$Request.compile(IMain.scala:997)
        at scala.tools.nsc.interpreter.IMain.compile(IMain.scala:579)
        at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:567)
        at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:565)
        at scala.tools.nsc.interpreter.ILoop.interpretStartingWith(ILoop.scala:807)
        at scala.tools.nsc.interpreter.ILoop.command(ILoop.scala:681)
        at scala.tools.nsc.interpreter.ILoop.processLine(ILoop.scala:395)
        at scala.tools.nsc.interpreter.ILoop.loop(ILoop.scala:415)
        at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply$mcZ$sp(ILoop.scala:923)
        at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:909)
        at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:909)
        at scala.reflect.internal.util.ScalaClassLoader$.savingContextLoader(ScalaClassLoader.scala:97)
        at scala.tools.nsc.interpreter.ILoop.process(ILoop.scala:909)
        at scala.tools.nsc.interpreter.ILoop.main(ILoop.scala:934)
        at xsbt.ConsoleInterface.run(ConsoleInterface.scala:62)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:101)
        at sbt.compiler.AnalyzingCompiler.console(AnalyzingCompiler.scala:76)
        at sbt.Console.sbt$Console$$console0$1(Console.scala:22)
        at sbt.Console$$anonfun$apply$2$$anonfun$apply$1.apply$mcV$sp(Console.scala:23)
        at sbt.Console$$anonfun$apply$2$$anonfun$apply$1.apply(Console.scala:23)
        at sbt.Console$$anonfun$apply$2$$anonfun$apply$1.apply(Console.scala:23)
        at sbt.Logger$$anon$4.apply(Logger.scala:84)
        at sbt.TrapExit$App.run(TrapExit.scala:248)
        at java.lang.Thread.run(Thread.java:745)
@scabug

This comment has been minimized.

Copy link
Author

scabug commented Jun 30, 2016

Imported From: https://issues.scala-lang.org/browse/SI-9839?orig=1
Reporter: kenji yoshida
Affected Versions: 2.11.8, 2.12.0-M5
See #9852

@scabug

This comment has been minimized.

Copy link
Author

scabug commented Sep 21, 2016

@som-snytt said:
Just ignores the bad name position.

scala/scala#5402

@scabug scabug added this to the 2.12.2 milestone Apr 7, 2017

@SethTisue SethTisue closed this Apr 10, 2017

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