-
Notifications
You must be signed in to change notification settings - Fork 21
"error: ')' expected but eof found." after Scala 2.12.13 #12317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
do you think this is a bug in scalac? a change/bug in the API that sbt uses to call into the compiler? |
Yea. If I understand correctly sbt uses the parser to figure out the expression boundary, and it seems something changed that it's now off by one? |
Perhaps it's configurable warnings that's tripping up sbt's parsing. |
Perhaps the next thing here would be to bisect it using Scala nightlies to figure out what scala/scala PR caused the change. That almost always either makes it obvious what happened, or at least makes it obvious where to look. |
I started the bisect, and compiling new Scala versions was pretty simple - but when it came to compiling the SBT with said bisect (random SNAPSHOT version) I wasn't smart to figure out what to do. Bumping the Scala version requires bumping the linked dependencies which require an exact Scala version (e.g. kind-projector and others) and this didn't resolve. |
You don't need to compile the Scala versions yourself, you can use our published nightlies. But yeah, The alternative is to use the community build, which builds everything from source. That route works well but does require learning the community build ropes a bit. It's reasonably well documented. You can One thing I don't know is why the community build didn't already detect this problem for us. Is the version we have in https://github.com/scala/community-build/blob/2.12.x/proj/sbt.conf too old? Or does sbt's test suite not detect the problem? |
Oh wow it really is very old (1.2.1). Tell you what: I will try to bring that up-to-date myself. I may hit some roadblock but there's a good chance I won't. I'll report back here. |
@eed3si9n do you have a branch somewhere with your changes for 2.12.13? Or was it just a version number bump, no other changes? |
My PR that I originally ran into this is here - sbt/sbt#6261 Within sbt you can run:
which should trigger the error. I'm guessing you should be able to get the error also by just changing |
I have now merged scala/community-build#1345, but it didn't reproduce the bug @eed3si9n is it clear to you why? do I just need to enable an additional subproject or something? (and is this worth pursuing further in the context of the community build? I'm happy to have done the 1345 work, but let's only keep going, in the community build context, if doing so seems worth it) |
I'll check to see if I can reproduce this with just the Scala version bump. |
I created a smaller PR sbt/sbt#6291, and I'm still seeing the issue. |
Assuming I've done the bisection correctly, the culprit looks to be scala/scala#9248
|
To provide a bit more context on sbt side, we first try to parse the whole source, then try to split them into individual lazy val root = project.in(file("."))
lazy val sub1 = project.in(file("sub1"))
lazy val sub2 = project.in(file("sub2"))
lazy val sub3 = project.in(file("sub3")) even though the input was lazy val root = (project in file("."))
lazy val sub1 = (project in file("sub1"))
lazy val sub2 = (project in file("sub2"))
lazy val sub3 = (project in file("sub3")) so when sbt tries to reconstruct the expression it becomes off-by-one My guess of what's happening is that scala/scala#9248 being the cause makes sense since that's the only change made to Parser / Scanner on 2.12.13? |
The scalac 2 parser doesn't preserve parens and text. If you want the line of source, you can My other thought is that REPL parses progressively because it's trying to detect when it has enough to compile. sbt could also do that, with the advantage of always knowing the next line, so it can re-parse with the next line to detect whether it is agglutinative. (After I haven't looked at the sbt code, ergo sorry if this observation isn't relevant. (That is, this issue makes me want to look at sbt code.) |
Scala compiler changed the implementation of reporter in 2.12.13 such that overriding `info0` no longer increments the error count in the delegating reporter. See scala/bug#12317 for details.
Since My sort-of minimized partest is https://gist.github.com/eed3si9n/5cb9572eac9f2be11ae3a42cd25174ec, and after manually binary searching scala/scala#9248 it seems like the first bad commit is scala/scala@8ee5e80.
Changing the parent class from - def warning(pos: Position, msg: String): Unit = info0(pos, msg, WARNING, force = false)
- def error(pos: Position, msg: String): Unit = info0(pos, msg, ERROR, force = false)
+ def warning(pos: Position, msg: String): Unit = {
+ val f = filter(pos, msg, WARNING)
+ if (f <= 1) increment(WARNING)
+ if (f == 0) info0(pos, msg, WARNING, force = false)
+ }
+
+ def error(pos: Position, msg: String): Unit = {
+ val f = filter(pos, msg, ERROR)
+ if (f <= 1) increment(ERROR)
+ if (f == 0) info0(pos, msg, ERROR, force = false)
+ } Previously, aspiring reporter aggregators like sbt could override just + override def warning(pos: Position, msg: String): Unit =
+ getReporter(pos.source.file.name).warning(pos, msg)
+
+ override def error(pos: Position, msg: String): Unit =
+ getReporter(pos.source.file.name).error(pos, msg) |
Overriding override def filter(pos: Position, msg: String, severity: Severity): Int = {
val reporter = getReporter(pos.source.file.name)
val result = reporter.filter(pos, msg, severity)
if (result <= 1) reporter.increment(severity)
if (result == 0) reporter.doReport(pos, msg, severity)
result
} It effectively reimplements |
Uh oh!
There was an error while loading. Please reload this page.
reproduction steps
Locally build sbt using Scala 2.12.13 and run:
Partest for this is https://gist.github.com/eed3si9n/5cb9572eac9f2be11ae3a42cd25174ec
problem
This causes
expectation
No error.
notes
The relevant place in sbt code is https://github.com/sbt/sbt/blob/4b71de0098b1f28b3d8ec6fa93e87cc5c9d50809/main-actions/src/main/scala/sbt/compiler/Eval.scala#L401-L408. It's possible I messed some other thing while upgrading to Scala 2.12.13, but figured I'd report this in case this pops up in a different way elsewhere.
The text was updated successfully, but these errors were encountered: