-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Fix inline anonymous functions causing a parsing error in p5.strands callbacks #7956
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
Fix inline anonymous functions causing a parsing error in p5.strands callbacks #7956
Conversation
🎉 Thanks for opening this pull request! For guidance on contributing, check out our contributor guidelines and other resources for contributors! Thank You! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding this, and the test as well! Just one minor comment about leaving some context for the change behind.
@@ -19,7 +19,7 @@ function shadergenerator(p5, fn) { | |||
if (shaderModifier instanceof Function) { | |||
let generatorFunction; | |||
if (options.parser) { | |||
const sourceString = shaderModifier.toString() | |||
const sourceString = `(${shaderModifier.toString()})`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mind adding a comment here to explain to other contributors why the brackets are necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would something like this work?
// #7955 Wrap function declaration code in brackets so anonymous functions are not top level statements, which causes an error in acorn when parsing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I will be able to make a commit later today
@all-contributors please add @nking07049925 for code |
I've put up a pull request to add @nking07049925! 🎉 |
Resolves #7955
Changes:
WebGL
ShaderGenerator.js
Unit Tests
p5.Shader
for an anonymous function being passed into the shaderScreenshots of the change
Example from the issue running locally with no errors

PR Checklist
npm run lint
passes