Go Down

Topic: autoformat bug with syntactical error in for loop (Read 866 times) previous topic - next topic

ahdavidson

I am getting an error using the Auto Format command when there is a syntactical error in a for loop specifier. (MacOS 10.5.7, Arduino 0016)

When the for statement has commas for separators instead of semi-colons, the IDE thinks for a very long time when asked to Auto Format the sketch, and then yields the message:

Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space

The compiler will correctly diagnose the error, however.

Here is a very simple sketch that demonstrates the error:

Code: [Select]

int i;

void setup () {
}

void loop () {
 for (i = 0, i < 10, i++)
 ;
}


Thanks.
.andy


.andy

AlphaBeta

#1
Jun 05, 2009, 12:51 am Last Edit: Jun 05, 2009, 12:58 am by AlphaBeta Reason: 1
Commas as separator in a for loop structure, is a compile error.

Actually, the only time I can think of, that the comma is a separator, not an operator, is in arguments lists.


Why not use semicolons?

ahdavidson

I know that it's not the right syntax; it was just a typo on my part when entering the code in the sketch. And the compiler did catch it.

But the auto-formatter did NOT catch it, or at least did not recover gracefully from parsing the erroneous syntax, and crashed.

So I'm just reporting this as an auto-formatter bug...
.andy

The Clever Monkey

Yup, it is falling off the end of the world trying to make sense of that bad code.  The parsing stuff looks ok, but it might be the display code wanting to display things over and over.
I yield() for co-routines.

paulb

The autoformat function is still pretty buggy and is best avoided until after you have made sure that the program compiles.

It used to have a charming "auto-delete" bug where code was deleted if brackets weren't balanced (which balanced the code) but that one has been fixed for a while. There are still many bugs and quirks in it though so compile first - and you'll be happier.

Go Up