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:
111
111
choices match
112
112
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)
113
113
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
115
118
catch case _ : NumberFormatException => fail(s " $argValue is not an integer argument for $name" , args)
116
119
117
120
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 {
218
218
assertFalse(" Multiple conflicting options is a warning" , summary.warnings.isEmpty)
219
219
assertTrue(summary.warnings.forall(_.contains(" updated" )))
220
220
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
+
221
230
// use the supplied summary for evaluating settings
222
231
private def withProcessedArgs (summary : ArgsSummary )(f : SettingsState ?=> Unit ) = f(using summary.sstate)
223
232
You can’t perform that action at this time.
0 commit comments