Skip to content

Commit 2fbf8d9

Browse files
committed
Properly report errors when cli flags are malformed
Previously we returned an empty Reporter with no errors so partest reported the test as a success.
1 parent c83f58b commit 2fbf8d9

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

src/dotty/tools/dotc/Driver.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ abstract class Driver extends DotClass {
3131
ctx.error(ex.getMessage) // signals that we should fail compilation.
3232
ctx.reporter
3333
}
34-
else emptyReporter
34+
else ctx.reporter
3535

3636
protected def initCtx = (new ContextBase).initialCtx
3737

test/dotc/tests.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ class tests extends CompilerTest {
119119
@Test def neg_typedIdents() = compileDir(negDir, "typedIdents")
120120

121121
val negCustomArgs = negDir + "customArgs/"
122+
123+
@Test def neg_cli_error = compileFile(negCustomArgs, "cliError", List("-thisOptionDoesNotExist"))
124+
122125
@Test def neg_typers() = compileFile(negCustomArgs, "typers")(allowDoubleBindings)
123126
@Test def neg_overrideClass = compileFile(negCustomArgs, "overrideClass", scala2mode)
124127
@Test def neg_autoTupling = compileFile(negCustomArgs, "autoTuplingTest", args = "-language:noAutoTupling" :: Nil)

tests/neg/customArgs/cliError.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// nopos-error
2+
object Test

0 commit comments

Comments
 (0)