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],
87
87
setupRootCtx(this .settings ++ settings, rootCtx)
88
88
}
89
89
90
+ private val incompatibleOptions : Seq [String ] = Seq (
91
+ initCtx.settings.YbestEffort .name,
92
+ initCtx.settings.YwithBestEffortTasty .name
93
+ )
94
+
90
95
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
92
105
case Some ((files, ictx)) => inContext(ictx) {
93
106
shouldStart = true
94
107
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:
456
456
assertTrue(last, last.startsWith(" val res0: tpolecat.type = null" ))
457
457
assertTrue(last, last.endsWith(""" // result of "res0.toString" is null""" ))
458
458
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
+
459
470
object ReplCompilerTests :
460
471
461
472
private val pattern = Pattern .compile(" \\ r[\\ n]?|\\ n" );
You can’t perform that action at this time.
0 commit comments