File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -87,8 +87,21 @@ class ReplDriver(settings: Array[String],
8787 setupRootCtx(this .settings ++ settings, rootCtx)
8888 }
8989
90+ private val incompatibleOptions : Seq [String ] = Seq (
91+ initCtx.settings.YbestEffort .name,
92+ initCtx.settings.YwithBestEffortTasty .name
93+ )
94+
9095 private def setupRootCtx (settings : Array [String ], rootCtx : Context ) = {
91- setup(settings, rootCtx) match
96+ val incompatible = settings.intersect(incompatibleOptions)
97+ val filteredSettings =
98+ if ! incompatible.isEmpty then
99+ inContext(rootCtx) {
100+ out.println(i " Options incompatible with repl will be ignored: ${incompatible.mkString(" , " )}" )
101+ }
102+ settings.filter(! incompatible.contains(_))
103+ else settings
104+ setup(filteredSettings, rootCtx) match
92105 case Some ((files, ictx)) => inContext(ictx) {
93106 shouldStart = true
94107 if files.nonEmpty then out.println(i " Ignoring spurious arguments: $files%, % " )
Original file line number Diff line number Diff line change @@ -456,6 +456,17 @@ class ReplCompilerTests extends ReplTest:
456456 assertTrue(last, last.startsWith(" val res0: tpolecat.type = null" ))
457457 assertTrue(last, last.endsWith(""" // result of "res0.toString" is null""" ))
458458
459+ @ Test def `i21431 filter out best effort options` : Unit =
460+ initially :
461+ run(" :settings -Ybest-effort -Ywith-best-effort-tasty" )
462+ .andThen:
463+ run(" 0" ) // check for crash
464+ val last = lines()
465+ println(last)
466+ assertTrue(last(0 ), last(0 ) == (" Options incompatible with repl will be ignored: -Ybest-effort, -Ywith-best-effort-tasty" ))
467+ assertTrue(last(1 ), last(1 ) == (" val res0: Int = 0" ))
468+
469+
459470object ReplCompilerTests :
460471
461472 private val pattern = Pattern .compile(" \\ r[\\ n]?|\\ n" );
You can’t perform that action at this time.
0 commit comments