Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on "PApplet" message caused by AST issues #3278

Open
shiffman opened this issue May 12, 2015 · 2 comments
Open

Error on "PApplet" message caused by AST issues #3278

shiffman opened this issue May 12, 2015 · 2 comments
Assignees

Comments

@shiffman
Copy link
Member

Picking up on #3253, the following code snippet:

void setup() {
  float w = random(20, 300);
  float x = random(w, width-w);
  float y = random(w/2, height-w/2);
  text(int(x) + ","  int(y), 50, 50);  // missing + between "," and int(y)
}

produces:

Error on "PApplet"`

I believe it should say:

Error on "int(y)"

(unless it can detect something more specific to the error itself.)

@benfry benfry changed the title Error on "PApplet" message Error on "PApplet" message caused by preprocessor issues Jun 16, 2015
@benfry benfry changed the title Error on "PApplet" message caused by preprocessor issues Error on "PApplet" message caused by AST issues Jun 16, 2015
@Manindra29
Copy link
Member

This occurs because presently there's no way for the eclipse compiler to differentiate between:
int(4.0) and PApplet.parseInt(4.0). All 'int()' are replaced with PApplet.parseInt() during the preprocessing stage, and at the moment, no book-keeping is done to keep track of which parseInt calls replaced int() calls.

Tldr; it's one of the corner cases for error checking. If this is a relatively common error? Then I can look into how to best handle it.

@shiffman
Copy link
Member Author

Ah, I see it's probably of an edge case but in theory it will pop up anytime there's an error at int(__). Do we have the same issues with errors around color()? My concern here is the use of PApplet which will cause confusion. So two ideas are:

  • Grab the token before PApplet.parseInt(). In this case it would then say Error on ",".
  • Just change it to say Unknown error (or something like that).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants