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

Undeclared variable 'g' not faulted at edit time and can lead to run-time errors. #5407

Closed
chrisjj opened this issue Feb 14, 2018 · 4 comments
Labels
cantfix This issue is out of our control

Comments

@chrisjj
Copy link

chrisjj commented Feb 14, 2018

Expected Behavior

Edit-time error: 'The variable 'g' does not exist.'

Current Behavior

No edit-time error. Sometimes run-time error: 'NulPointerException' (sic).

Steps to Reproduce

In an empty sketch, enter

g=null;

on in a real sketch, accidentally include that statement out of scope of a declaration of g in the sketch.

Your Environment

  • Processing version:
    3.3.6
  • Operating System and OS version:
    Windows 7.

Possible Causes / Solutions

Processing's internal 'g' varaible leaking into the sketch's scope.

@chrisjj chrisjj changed the title Undeclared variable 'g' not faulted and can lead to run-time errors. Undeclared variable 'g' not faulted at edit time and can lead to run-time errors. Feb 14, 2018
@MLanghof
Copy link

MLanghof commented Feb 21, 2018

That's because there is a PGraphics object named g in the same class your code gets placed in - it's the thing you effectively draw on. And if you set that one to null, bad things will happen indeed.

@benfry
Copy link
Contributor

benfry commented Mar 26, 2018

Closing since there's not a great solution for this; the g object is there and as implemented, we can't prevent people from messing with it.

@benfry benfry closed this as completed Mar 26, 2018
@benfry benfry added the cantfix This issue is out of our control label Mar 26, 2018
@chrisjj
Copy link
Author

chrisjj commented Mar 26, 2018

How about make the syntax checker fault use of a dangerous name?

Else add to the docs a warning and list of the dangerous names?

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cantfix This issue is out of our control
Projects
None yet
Development

No branches or pull requests

3 participants