does anybody know why in the developer console if you click on a curly bracket, the pair turn green. However if you click on some other curly brackets they turn red.

I'm pretty convinced this is not an error otherwise it would show in the problems tab, however I need to convince someone else of this and I can't find what the real reason is.

thanks kindly Jason


They are unmatched tokens. This means that the local parser has detected an unbalanced order of curly braces or parentheses. It's not perfect, however, as it can occasionally get confused, but it usually gets it right, and there may be compilation errors.

For example, there are four unmatched tokens in this code:

System.debug('(She says some {) great things }');

If you click on the curly braces or parentheses inside the string, they'll turn red, while the ones outside will turn green. Of course, in a string, they have no special meaning, so they do not need to be balanced. However, such an unbalance should never spread beyond the current block of code, or you almost certainly have a compiler error.

For example, consider this random garbage I just typed up:

class X {
    class Y {

    public void z() {
        if(true) {

        } else

If you put this into your Developer Console, the very last curly brace will be red. In this case, I actually (intentionally) missed a curly brace, so a compiler error would occur.

In some rare cases, you'll find some sort of construct that messes up the parser's internal state and a random curly brace or parentheses will appear red despite being properly matched. As long as the code saves successfully, I wouldn't worry about these rare exceptions.


It is just an inconsisency in the syntax highlighting logic. I have had this happen before and I was curious about is as well. It would could change the brackets from red to green just by adding and removing blank lines and comments. nothing to worry about. Definitely not an error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.