Skip to content

Commit 9fa18cc

Browse files
committed
SI-9377 Update ScalaVersion error text
Simplify and sweeten the message.
1 parent f187bde commit 9fa18cc

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

src/compiler/scala/tools/nsc/settings/ScalaVersion.scala

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,7 @@ object ScalaVersion {
7777

7878
def apply(versionString: String, errorHandler: String => Unit): ScalaVersion = {
7979
def error() = errorHandler(
80-
s"There was a problem parsing ${versionString}. " +
81-
"Versions should be in the form major[.minor[.revision]] " +
82-
"where each part is a positive number, as in 2.10.1. " +
83-
"The minor and revision parts are optional."
80+
s"Bad version (${versionString}) not major[.minor[.revision[-suffix]]]"
8481
)
8582

8683
def toInt(s: String) = s match {

test/junit/scala/tools/nsc/settings/ScalaVersionTest.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ class ScalaVersionTest {
5656
assertThrows[NumberFormatException] { ScalaVersion("2-") }
5757
assertThrows[NumberFormatException] { ScalaVersion("2-.") } // scalacheck territory
5858
assertThrows[NumberFormatException] { ScalaVersion("any.7") }
59+
60+
assertThrows[NumberFormatException] ( ScalaVersion("2.11-ok"), _ ==
61+
"Bad version (2.11-ok) not major[.minor[.revision[-suffix]]]" )
62+
5963
}
6064

6165
// SI-9377

test/junit/scala/tools/nsc/settings/SettingsTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,6 @@ class SettingsTest {
178178
check(expected = "2.12", "-Xsource:2.12")
179179
assertThrows[IllegalArgumentException](check(expected = "2.11", "-Xsource"), _ == "-Xsource requires an argument, the syntax is -Xsource:<version>")
180180
assertThrows[IllegalArgumentException](check(expected = "2.11", "-Xsource", "2.11"), _ == "-Xsource requires an argument, the syntax is -Xsource:<version>")
181-
assertThrows[IllegalArgumentException](check(expected = "2.11", "-Xsource:2.invalid"), _ contains "There was a problem parsing 2.invalid")
181+
assertThrows[IllegalArgumentException](check(expected = "2.11", "-Xsource:2.invalid"), _ contains "Bad version (2.invalid)")
182182
}
183183
}

0 commit comments

Comments
 (0)