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 @@ -111,7 +111,10 @@ object Settings:
111111 choices match
112112 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)
113113 case Some (xs) if ! xs.contains(x) => fail(s " $argValue is not a valid choice for $name" , args)
114- case _ => update(x, args)
114+ case _ =>
115+ val dubious = changed && x != valueIn(sstate).asInstanceOf [Int ]
116+ val updated = update(x, args)
117+ if dubious then updated.warn(s " Option $name was updated " ) else updated
115118 catch case _ : NumberFormatException => fail(s " $argValue is not an integer argument for $name" , args)
116119
117120 def doSet (argRest : String ): ArgsSummary = (summon[ClassTag [T ]]: @ unchecked) match {
Original file line number Diff line number Diff line change @@ -218,6 +218,15 @@ class SettingsTests {
218218 assertFalse(" Multiple conflicting options is a warning" , summary.warnings.isEmpty)
219219 assertTrue(summary.warnings.forall(_.contains(" updated" )))
220220
221+ @ Test def `int option also warns` : Unit =
222+ object Settings extends SettingGroup :
223+ val option = IntSetting (" -option" , " Some option" , 42 )
224+ val args = List (" -option:17" , " -option:27" )
225+ val summary = Settings .processArguments(args, processAll = true )
226+ assertTrue(" Multiple options is not an error" , summary.errors.isEmpty)
227+ assertFalse(" Multiple conflicting options is a warning" , summary.warnings.isEmpty)
228+ assertTrue(summary.warnings.forall(_.contains(" updated" )))
229+
221230 // use the supplied summary for evaluating settings
222231 private def withProcessedArgs (summary : ArgsSummary )(f : SettingsState ?=> Unit ) = f(using summary.sstate)
223232
You can’t perform that action at this time.
0 commit comments