Skip to content

Commit 7ccdfbc

Browse files
authored
Merge pull request #13267 from dwijnand/support-int-set-with-colon
2 parents 38b983c + 38a27db commit 7ccdfbc

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ object Settings:
130130
val output = if (isJar) JarArchive.create(path) else new PlainDirectory(path)
131131
update(output, args)
132132
}
133-
case (IntTag, arg2 :: args2) =>
133+
case (IntTag, _) =>
134+
val arg2 :: args2 = if (argRest == "") args else argRest :: args
134135
try {
135136
val x = arg2.toInt
136137
choices match {

compiler/test/dotty/tools/dotc/SettingsTests.scala

+12
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,18 @@ class SettingsTests {
165165
assertEquals(expectedErrors, summary.errors)
166166
}
167167

168+
@Test def `Allow IntSetting's to be set with a colon`: Unit =
169+
object Settings extends SettingGroup:
170+
val foo = IntSetting("-foo", "foo", 80)
171+
import Settings._
172+
173+
val args = List("-foo:100")
174+
val summary = processArguments(args, processAll = true)
175+
assertTrue(s"Setting args errors:\n ${summary.errors.take(5).mkString("\n ")}", summary.errors.isEmpty)
176+
withProcessedArgs(summary) {
177+
assertEquals(100, foo.value)
178+
}
179+
168180
private def withProcessedArgs(summary: ArgsSummary)(f: SettingsState ?=> Unit) = f(using summary.sstate)
169181

170182
extension [T](setting: Setting[T])

0 commit comments

Comments
 (0)