diff --git a/main/src/main/scala/sbt/internals/parser/SbtParser.scala b/main/src/main/scala/sbt/internals/parser/SbtParser.scala
index 08d71c736..6050d08be 100644
--- a/main/src/main/scala/sbt/internals/parser/SbtParser.scala
+++ b/main/src/main/scala/sbt/internals/parser/SbtParser.scala
@@ -95,6 +95,21 @@ private[sbt] case class SbtParser(file: File, lines: Seq[String]) extends Parsed
Seq(t)
}
+ // Check No val (a,b) = foo *or* val a,b = foo as these are problematic to range positions and the WHOLE architecture.
+ def isBadValDef(t: Tree): Boolean =
+ t match {
+ case (x @ (toolbox.u.ValDef(_, _, _, _) | toolbox.u.DefDef(_, _, _, _, _, _))) =>
+ val content = modifiedContent.substring(x.pos.start, x.pos.end)
+ val prettyPrint = x.toString
+ (!(content contains "=") && (prettyPrint contains "="))
+ case _ => false
+ }
+ parsedTrees.filter(isBadValDef).foreach { badTree =>
+ // Issue errors
+ val positionLine = badTree.pos.line
+ throw new MessageOnlyException(s"""[$fileName]:$positionLine: Pattern matching in val statements is not supported""".stripMargin)
+ }
+
val (imports, statements) = parsedTrees partition {
case _: Import => true
case _ => false
diff --git a/main/src/test/resources/error-format/4.sbt.txt b/main/src/test/resources/error-format/4.sbt.txt
new file mode 100644
index 000000000..34381a270
--- /dev/null
+++ b/main/src/test/resources/error-format/4.sbt.txt
@@ -0,0 +1 @@
+val a,b = project
\ No newline at end of file
diff --git a/main/src/test/resources/old-format/21.sbt.txt b/main/src/test/resources/old-format/21.sbt.txt
index c4cfc8585..064e513f8 100644
--- a/main/src/test/resources/old-format/21.sbt.txt
+++ b/main/src/test/resources/old-format/21.sbt.txt
@@ -1,72 +1,5 @@
+val x = bar
-name := "scala-stm"
-
-organization := "org.scala-stm"
-
-version := "0.8-SNAPSHOT"
-
-scalaVersion := "2.11.2"
-
-crossScalaVersions := Seq("2.11.2", "2.10.4", "2.9.3")
-
-libraryDependencies += ("org.scalatest" %% "scalatest" % "[1.5,)" % "test")
-
-libraryDependencies += ("junit" % "junit" % "4.5" % "test")
-
-// skip exhaustive tests
-testOptions += Tests.Argument("-l", "slow")
-
-// test of TxnExecutor.transformDefault must be run by itself
-parallelExecution in Test := false
-
-////////////////////
-// publishing
-
-pomExtra :=
- http://nbronson.github.com/scala-stm/
-
-
- BSD
- https://github.com/nbronson/scala-stm/blob/master/LICENSE.txt
- repo
-
-
-
- scm:git:git@github.com:nbronson/scala-stm.git
- git@github.com:nbronson/scala-stm.git
-
-
-
- nbronson
- Nathan Bronson
- ngbronson@gmail.com
-
-
-
-publishMavenStyle := true
-
-publishTo <<= (version) { v: String =>
- val base = "https://oss.sonatype.org/"
- if (v.trim.endsWith("SNAPSHOT"))
- Some("snapshots" at base + "content/repositories/snapshots/")
- else
- Some("releases" at base + "service/local/staging/deploy/maven2/")
- }
-
-// exclude scalatest from the Maven POM
-pomPostProcess := { xi: scala.xml.Node =>
- import scala.xml._
- val badDeps = (xi \\ "dependency") filter {
- x => (x \ "artifactId").text != "scala-library"
- } toSet
- def filt(root: Node): Node = root match {
- case x: Elem => {
- val ch = x.child filter { !badDeps(_) } map { filt(_) }
- Elem(x.prefix, x.label, x.attributes, x.scope, ch: _*)
- }
- case x => x
- }
- filt(xi)
- }
-
-credentials += Credentials(Path.userHome / ".ivy2" / ".credentials")
+{
+ val a,b = project
+}
diff --git a/main/src/test/resources/old-format/22.sbt.txt b/main/src/test/resources/old-format/22.sbt.txt
new file mode 100644
index 000000000..4b6e131ae
--- /dev/null
+++ b/main/src/test/resources/old-format/22.sbt.txt
@@ -0,0 +1,71 @@
+name := "scala-stm"
+
+organization := "org.scala-stm"
+
+version := "0.8-SNAPSHOT"
+
+scalaVersion := "2.11.2"
+
+crossScalaVersions := Seq("2.11.2", "2.10.4", "2.9.3")
+
+libraryDependencies += ("org.scalatest" %% "scalatest" % "[1.5,)" % "test")
+
+libraryDependencies += ("junit" % "junit" % "4.5" % "test")
+
+// skip exhaustive tests
+testOptions += Tests.Argument("-l", "slow")
+
+// test of TxnExecutor.transformDefault must be run by itself
+parallelExecution in Test := false
+
+////////////////////
+// publishing
+
+pomExtra :=
+ http://nbronson.github.com/scala-stm/
+
+
+ BSD
+ https://github.com/nbronson/scala-stm/blob/master/LICENSE.txt
+ repo
+
+
+
+ scm:git:git@github.com:nbronson/scala-stm.git
+ git@github.com:nbronson/scala-stm.git
+
+
+
+ nbronson
+ Nathan Bronson
+ ngbronson@gmail.com
+
+
+
+publishMavenStyle := true
+
+publishTo <<= (version) { v: String =>
+ val base = "https://oss.sonatype.org/"
+ if (v.trim.endsWith("SNAPSHOT"))
+ Some("snapshots" at base + "content/repositories/snapshots/")
+ else
+ Some("releases" at base + "service/local/staging/deploy/maven2/")
+ }
+
+// exclude scalatest from the Maven POM
+pomPostProcess := { xi: scala.xml.Node =>
+ import scala.xml._
+ val badDeps = (xi \\ "dependency") filter {
+ x => (x \ "artifactId").text != "scala-library"
+ } toSet
+ def filt(root: Node): Node = root match {
+ case x: Elem => {
+ val ch = x.child filter { !badDeps(_) } map { filt(_) }
+ Elem(x.prefix, x.label, x.attributes, x.scope, ch: _*)
+ }
+ case x => x
+ }
+ filt(xi)
+ }
+
+credentials += Credentials(Path.userHome / ".ivy2" / ".credentials")
diff --git a/main/src/test/scala/sbt/internals/parser/SplitExpressionsFilesTest.scala b/main/src/test/scala/sbt/internals/parser/SplitExpressionsFilesTest.scala
index bf566aa54..327dbc7e2 100644
--- a/main/src/test/scala/sbt/internals/parser/SplitExpressionsFilesTest.scala
+++ b/main/src/test/scala/sbt/internals/parser/SplitExpressionsFilesTest.scala
@@ -136,6 +136,7 @@ abstract class AbstractSplitExpressionsFilesTest(pathName: String) extends Speci
println(s"In file: $fileName, old splitter failed. ${ex.toString}")
case SplitterComparison(_, util.Failure(ex)) =>
println(s"In file: $fileName, new splitter failed. ${ex.toString}")
+ ex.printStackTrace()
case SplitterComparison(util.Success(resultOld), util.Success(resultNew)) =>
if (resultOld == resultNew) {
println(s"In file: $fileName, same results (imports, settings): $resultOld")
diff --git a/sbt/src/sbt-test/project/defs/build.sbt b/sbt/src/sbt-test/project/defs/build.sbt
index d8e736d74..f5dca00bb 100644
--- a/sbt/src/sbt-test/project/defs/build.sbt
+++ b/sbt/src/sbt-test/project/defs/build.sbt
@@ -1,3 +1,5 @@
+lazy val a,b = project
+
def now = System.currentTimeMillis
lazy val v = "1.0-" +
@@ -10,3 +12,5 @@ val descr = "Description"
name := n
version := v
+
+