Bug 1377 : weird compiler behaviour
Last modified: 2010-02-16 12:35




Status:
RESOLVED
Resolution:
DUPLICATE of bug 1362
Priority:
P2
Severity:
normal

 

Reporter:
antiplastik
Assigned To:
fry

Attachment Type Created Size Actions
Archived sketch application/zip 2010-02-14 05:42 805 bytes

Description:   Opened: 2009-11-28 12:48
The following code won't compile :

[code]
void turns(float angle) {
if (angle < 0) {
new SmokeParticle(new PVector(pt[2].x, pt[2].y));
}
else {
// int a = 1;
new SmokeParticle(new PVector(pt[1].x, pt[1].y)); // <-- error here
}
this.rot += angle;
}
[/code]

saying "Syntax error on token "}", { expected after this token" on line 7

remove the comment on line 6 and it works. weird!
Additional Comment #1 From antiplastik 2009-11-28 12:49
removing the brackets on if / else statement will work too.
Additional Comment #2 From fry 2009-11-28 12:51
did you define "class SmokeParticle" on the first tab, and before your
other code? (e.g. setup() et al) if so, move it to another tab and try again.
Additional Comment #3 From antiplastik 2010-02-14 05:41
> did you define "class SmokeParticle" on
> the first tab, and before your other code?

No. I tried with separate tabs, but it still gives this weird compiler error.

Full code below (or see attached archive file).


// ========= sketch_feb14c.pde
Ship ship;

void setup() {
size(200, 200);
ship = new Ship();
}

void draw() {
background(255);
}

// ========= Ship.pde
class Ship {

float rot;

Ship() {}

void turns(float angle) {
PVector[] pt = new PVector[] { new PVector(), new PVector(), new
PVector() };
if (angle < 0) {
new SmokeParticle(new PVector(pt[2].x, pt[2].y));
}
else {
//int a = 1;
new SmokeParticle(new PVector(pt[1].x, pt[1].y)); // <-- error here
}
this.rot += angle;
}

}

// ========= SmokeParticle.pde
class SmokeParticle {

PVector pos;

SmokeParticle(PVector p) {
pos = p;
}

}
Additional Comment #4 From antiplastik 2010-02-14 05:42
edit]
Archived sketch
Additional Comment #5 From antiplastik 2010-02-16 12:34
This bug is a duplicate.

See #1362
http://dev.processing.org/bugs/show_bug.cgi?id=1362
Additional Comment #6 From fry 2010-02-16 12:35


*** This bug has been marked as a duplicate of 1362 ***