Pages: [1]   Go Down
Author Topic: autoformat bug with syntactical error in for loop  (Read 766 times)
0 Members and 1 Guest are viewing this topic.
Seattle, USA
Offline Offline
Full Member
***
Karma: 0
Posts: 248
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
int i;

void setup () {
}

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

Thanks.
.andy


Logged

.andy

Norway@Oslo
Offline Offline
Edison Member
*
Karma: 12
Posts: 2033
loveArduino(true);
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
« Last Edit: June 04, 2009, 05:58:55 pm by AlphaBeta » Logged

Seattle, USA
Offline Offline
Full Member
***
Karma: 0
Posts: 248
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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...
Logged

.andy

Canada
Offline Offline
Full Member
***
Karma: 0
Posts: 246
Code Monkey
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

I yield() for co-routines.

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 267
dinosaur cork
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: