Page 1 of 1
Mismatched brackets error message
Posted: Sat Mar 06, 2021 4:58 am
by BarryG
Check out this snippet:
Code: Select all
Dim a$(1)
Dim b(1)
b$=Left(a$(1),Len(a$(1))-b(1)))
b$=Left(a$(1),Len(a$(1))-b(1)
At first glance, they look fine. But the first b$ line gives an error of
Garbage at the end of the line, and the second gives a
Syntax error.
However, both these error messages are not very helpful to immediately and intuitively indicate what the problem is.
I'd rather see an error message like this:
Opening and closing brackets are mismatched.
Re: Mismatched brackets error message
Posted: Tue Mar 09, 2021 8:18 am
by mrv2k
If you go to Preferences - Coloring and scroll down a bit, there is an option for "Mark mismatched Braces and Keywords". Make sure that is ticked and a colour is set. If you tick the option above "Mark matching Braces and Keywords" it's easier to see when you are writing the command.
Re: Mismatched brackets error message
Posted: Tue Mar 09, 2021 10:07 am
by BarryG
Yep, I know about that, and I do have it set. However, when pasting a copied line (or block of code) like that, are you really going to sit there and cursor through all lines to make sure all the brackets match? Nope. You just want to compile and go; not check and count all the brackets manually. So, this is more about changing the error message, which doesn't indicate the true problem.
I'd even say that checking for mismatched brackets would increase compile time, because if the brackets don't match then the entire line (and any other commands on it) can immediately be ignored (since the line won't compile until the brackets are resolved).
Re: Mismatched brackets error message
Posted: Tue Mar 09, 2021 10:36 am
by Marc56us
BarryG wrote:I'd rather see an error message like this: Opening and closing brackets are mismatched.
Yes, but this would require specific processing (so slow down), because currently this message is generic for a lot of characters.
Give it a try:
( ) { } [ ]
but also, this is the same message for:
# " ' @ ` ^
So '
Garbage at the End of the line' says that the error starts there and that it's useless to go any further.
Same thing for '
Syntax error' this is basic error.
Matching brackets when displaying is a feature of Scintilla in the IDE. For the compiler to do it itself, I think it would require a lot of extra processing.
IMHO
