Skip to content

Commit a1d7db2

Browse files
authored
Merge pull request #2590 from typeness/fix-#2369
Fix #2369: Should warn when ignoring command line flags
2 parents f7052d4 + 08f1233 commit a1d7db2

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

compiler/src/dotty/tools/dotc/config/Settings.scala

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ object Settings {
6565
depends: List[(Setting[_], Any)] = Nil,
6666
propertyClass: Option[Class[_]] = None)(private[Settings] val idx: Int) {
6767

68+
private var changed: Boolean = false
69+
6870
def withAbbreviation(abbrv: String): Setting[T] =
6971
copy(aliases = aliases :+ abbrv)(idx)
7072

@@ -111,8 +113,14 @@ object Settings {
111113

112114
def tryToSet(state: ArgsSummary): ArgsSummary = {
113115
val ArgsSummary(sstate, arg :: args, errors, warnings) = state
114-
def update(value: Any, args: List[String]) =
115-
ArgsSummary(updateIn(sstate, value), args, errors, warnings)
116+
def update(value: Any, args: List[String]) = {
117+
if (changed) {
118+
ArgsSummary(updateIn(sstate, value), args, errors, warnings :+ s"Flag $name set repeatedly")
119+
} else {
120+
changed = true
121+
ArgsSummary(updateIn(sstate, value), args, errors, warnings)
122+
}
123+
}
116124
def fail(msg: String, args: List[String]) =
117125
ArgsSummary(sstate, args, errors :+ msg, warnings)
118126
def missingArg =

0 commit comments

Comments
 (0)