Skip to content
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

Confusing Unmatched closing brace errors #2968

Closed
scabug opened this issue Jan 26, 2010 · 12 comments
Closed

Confusing Unmatched closing brace errors #2968

scabug opened this issue Jan 26, 2010 · 12 comments

Comments

@scabug
Copy link

@scabug scabug commented Jan 26, 2010

Particularly with longer source files, introducing a wrong or missing brace or paranthesis may result in a compiler error that spots the mistake at a perfectly fine spot, making it practically impossible to find the real mistake. Finding the mistake in the attached source will take me twenty to thirty minutes.

Expected behaviour: the compiler should report the most likely spot for the mistake, instead of giving up at an arbitrary position.

@scabug
Copy link
Author

@scabug scabug commented Jan 26, 2010

Imported From: https://issues.scala-lang.org/browse/SI-2968?orig=1
Reporter: @Sciss
Attachments:

Loading

@scabug
Copy link
Author

@scabug scabug commented Jan 26, 2010

@Sciss said:
p.s. here are the compiler errors emitted from the above files:

/Users/rutz/Documents/devel/Kontur/src/de/sciss/kontur/gui/TrackComponent.scala:32: error: Unmatched closing brace '}' ignored here
RenderingHints }
/Users/rutz/Documents/devel/Kontur/src/de/sciss/kontur/gui/TrackComponent.scala:33: error: '}' expected but ';' found.
import java.awt.datatransfer.{ DataFlavor, Transferable }
/Users/rutz/Documents/devel/Kontur/src/de/sciss/kontur/gui/TrackComponent.scala:442: error: eof expected but '}' found.
}
three errors found

Loading

@scabug
Copy link
Author

@scabug scabug commented Feb 1, 2010

@lindydonna said:
Please include a smaller reproducible case--there's so much extraneous code here that it's hard to see what's going on in the parser.

Loading

@scabug
Copy link
Author

@scabug scabug commented Feb 8, 2010

@axel22 said:
Could you please add a smaller example of this, and one not using external libraries? This could make it easier to analyze parser behaviour.

Thanks

Loading

@scabug
Copy link
Author

@scabug scabug commented Oct 21, 2012

Nick Vrvilo (daowen) said:
Smaller reproducible case (< 20 loc).

Loading

@scabug
Copy link
Author

@scabug scabug commented Oct 21, 2012

Nick Vrvilo (daowen) said (edited on Oct 21, 2012 6:18:02 PM UTC):
It looks like this ticket was closed because the submitter never posted a smaller sample that would reproduce the error. I've run into the same problem, and I've produced a very small representative example. I consider this a major flaw in the Scala compiler because forgetting closing braces is a common programming error and—as the original poster emphasized—the Scala compiler's misleading error messages makes it way too difficult to find the actual cause. A totally vague message like "you have a missing brace somewhere" would actually be more helpful than the current practice of reporting totally misleading line numbers.

I've tested the attached braces.scala with both 2.9.2 and 2.10.0 RC1. Both have the same misleading line numbers in the error messages.

I reopend this ticket after posting a question to StackOverflow related to this issue (http://stackoverflow.com/questions/12050166/scalac-missing-closing-brace-error-reports-with-weird-line-number). One of the members there commented that the Scala team believes that helpful error messages are important, and that I should post this issue to the bug tracker. I was surprised to find that an identical issue had been posted back in January 2010, but was never resolved. I hope that the example I've provided along with the lengthy description of the issue over at StackOverflow will help to resolve this issue.

Loading

@scabug
Copy link
Author

@scabug scabug commented Oct 21, 2012

@paulp said:
Thanks for reopening this - I am actually driven mad by the process of tracking down a missing brace, but I'm already fighting on so many fronts it's rare I allow myself to open new ones.

Loading

@scabug
Copy link
Author

@scabug scabug commented Oct 21, 2012

@retronym said:
A smaller version of the problem:

case class Const {
}    // missing '{' assumed here

class Var
{

It's actually a remarkably specific bug. Just take a look at the variations below, each of which is competently handled by the missing brace department.

case class Const
{
}

class Var
{
     // missing '{' assumed here
class Const {
}

class Var
{
     // missing '{' assumed here
object Const {
}

class Var
{
     // missing '{' assumed here
final case class Const {
}

class Var
{
     // missing '{' assumed here
@foo case class Const {
}

class Var
{
     // missing '{' assumed here
case
class Const {
}

class Var
{
     // missing '{' assumed here
case class
Const {
}

class Var
{
     // missing '{' assumed here

Loading

@scabug
Copy link
Author

@scabug scabug commented Oct 21, 2012

@retronym said:
This needs a bit more polish (I'm new to this neck of the woods), but seems to be an improvement:

https://github.com/retronym/scala/compare/ticket/2968

Loading

@scabug
Copy link
Author

@scabug scabug commented Oct 22, 2012

Loading

@scabug
Copy link
Author

@scabug scabug commented Jan 23, 2013

@adriaanm said:
reopening for potential backport to 2.10.1-RC1

Loading

@scabug
Copy link
Author

@scabug scabug commented Jan 26, 2013

@retronym said:
backport: scala/scala#1980

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants