File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
src/dotty/tools/dotc/config Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -110,7 +110,10 @@ object Settings:
110110 choices match
111111 case Some (r : Range ) if x < r.head || r.last < x => fail(s " $argValue is out of legal range ${r.head}.. ${r.last} for $name" , args)
112112 case Some (xs) if ! xs.contains(x) => fail(s " $argValue is not a valid choice for $name" , args)
113- case _ => update(x, args)
113+ case _ =>
114+ val dubious = changed && x != valueIn(sstate).asInstanceOf [Int ]
115+ val updated = update(x, args)
116+ if dubious then updated.warn(s " Option $name was updated " ) else updated
114117 catch case _ : NumberFormatException => fail(s " $argValue is not an integer argument for $name" , args)
115118
116119 def doSet (argRest : String ): ArgsSummary = (summon[ClassTag [T ]]: @ unchecked) match {
Original file line number Diff line number Diff line change @@ -216,6 +216,15 @@ class SettingsTests {
216216 assertFalse(" Multiple conflicting options is a warning" , summary.warnings.isEmpty)
217217 assertTrue(summary.warnings.forall(_.contains(" updated" )))
218218
219+ @ Test def `int option also warns` : Unit =
220+ object Settings extends SettingGroup :
221+ val option = IntSetting (" -option" , " Some option" , 42 )
222+ val args = List (" -option:17" , " -option:27" )
223+ val summary = Settings .processArguments(args, processAll = true )
224+ assertTrue(" Multiple options is not an error" , summary.errors.isEmpty)
225+ assertFalse(" Multiple conflicting options is a warning" , summary.warnings.isEmpty)
226+ assertTrue(summary.warnings.forall(_.contains(" updated" )))
227+
219228 // use the supplied summary for evaluating settings
220229 private def withProcessedArgs (summary : ArgsSummary )(f : SettingsState ?=> Unit ) = f(using summary.sstate)
221230
You can’t perform that action at this time.
0 commit comments