Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8720759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:06:26+00:00 2026-06-13T07:06:26+00:00

As I’ve been learning Scala I’m often reminded of g++ compiler errors when reading

  • 0

As I’ve been learning Scala I’m often reminded of g++ compiler errors when reading the cryptic output from scalac. However, today I came across something I doubt would happen even in the g++ universe.

A friend sent me a very simple code snippet with a fairly commonplace error:

case class Var(name: String) extends ArithExpr {
  override def eval(env: Env) =  env.lookup(name) match {
    case Some(d) => d
    case None => throw new IllegalArgumentException("Env " + env + " does not contain a binding for " + name)
  }
  override def exprString = name
// } // <-- MISSING THIS BRACE

The full source file is posted here. Since the case class Var class declaration is missing its closing brace you would think the compiler would tell you that the opening brace for that declaration (on line 11) is missing its closing brace. However, scalac reports that it “assumes” a missing closing brace in the middle of a previous case class declaration (on line 7). (The full error output is included at the bottom of the posted code.)

Most scalac error messages make sense if you understand the internals of the language, but I’m at a total loss here. How does a missing closing brace in a later class declaration end up propagating to an already successfully parsed class definition earlier in the file?

How on earth do you go about explaining this to a Scala beginner? Leaving off a closing brace is exactly the kind of mistake someone new to Scala might commonly do, but the error message here seems like it would lead the user so far astray that it would probably be more helpful to just report something like error: you seem to be missing a '}' somewhere instead.

Note: I know the usual answer to questions like this is just “use an IDE and the incremental compilation will flag it right away” or “syntax highlighting should make this error obvious”—but my question is asking specifically about the scalac output, so please keep in mind that I know those are valid points but I really just want to understand what is going on with the compiler here.

Update:

Let me try a different approach to explaining my confusion. The error stems from a missing closing brace, so it’s obviously a problem with brace nesting. Transforming the text (code) in the snippet I posted to a series of line-number+brace pairs we get this:

1{ 4}
6{ 9}
11{ 12{ 15}
    19{ 22}
    24{ 26}
    28{ 33}

We obviously have a missing closing brace. I could understand scalac guessing the missing brace could go in any one of these places (each represented by an x):

1{ 4}
6{ 9}
11{ x 12{ x 15} x <-- HERE OR HERE OR HERE
      19{ x 22} x <-- OR HERE OR HERE
      24{ x 26} x <-- OR HERE OR HERE
      28{ x 33} x <-- OR HERE OR HERE

However, this is what the output from scalac says:

   +----- I THINK YOU ARE MISSING A
   |      CLOSING BRACE RIGHT HERE!
1{ V 4}
6{ x 9} 
11{ 12{ 15}
    19{ 22}
    24{ 26}
    28{ 33}

That part of the input is already well-nested! How could adding another closing brace there possibly make any sense?

Edit: I feel like I should reiterate my main question again: How would you go about explaining this error message (and how to find the root of the error in the source) to a newcomer to Scala?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T07:06:27+00:00Added an answer on June 13, 2026 at 7:06 am

    Following Jörg W Mittag’s suggestion in his comment on my question, I’ve re-opened an old ticket in the Scala issue tracker: Confusing Unmatched closing brace errors. I’ve added the code from this question as a new, short, reproducible example of this class of confusing error messages.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.