Skip to content

Commit

Permalink
repl: Ignore spurious arguments in :settings
Browse files Browse the repository at this point in the history
  • Loading branch information
dwijnand committed Nov 22, 2021
1 parent cfa358b commit 7349e76
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 6 additions & 2 deletions compiler/src/dotty/tools/repl/ReplDriver.scala
Expand Up @@ -8,6 +8,7 @@ import dotty.tools.dotc.ast.{tpd, untpd}
import dotty.tools.dotc.config.CommandLineParser.tokenize
import dotty.tools.dotc.config.Properties.{javaVersion, javaVmName, simpleVersionString}
import dotty.tools.dotc.core.Contexts._
import dotty.tools.dotc.core.Decorators._
import dotty.tools.dotc.core.Phases.{unfusedPhases, typerPhase}
import dotty.tools.dotc.core.Denotations.Denotation
import dotty.tools.dotc.core.Flags._
Expand Down Expand Up @@ -424,8 +425,11 @@ class ReplDriver(settings: Array[String],
case _ =>
setup(tokenize(arg).toArray, rootCtx) match
case Some((files, ictx)) =>
ictx.base.initialize()(using ictx)
rootCtx = ictx
inContext(ictx) {
if files.nonEmpty then out.println(i"Ignoring spurious arguments: $files%, %")
ictx.base.initialize()(using ictx)
rootCtx = ictx
}
case _ =>
state.copy(context = rootCtx)

Expand Down
3 changes: 2 additions & 1 deletion compiler/test-resources/repl/settings-command
Expand Up @@ -2,7 +2,8 @@ scala> def f(thread: Thread) = thread.stop()
there were 1 deprecation warning(s); re-run with -deprecation for details
def f(thread: Thread): Unit

scala>:settings -deprecation
scala>:settings -deprecation foo.scala
Ignoring spurious arguments: foo.scala

scala> def f(thread: Thread) = thread.stop()
1 warning found
Expand Down

0 comments on commit 7349e76

Please sign in to comment.