-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Keep p5.strands transpiler output valid for comma-joined expressions #9193
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
Merged
davepagurek
merged 4 commits into
processing:main
from
harshiltewari2004:fix-strands-comma-operator
Sep 22, 2026
+209
−96
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
195e6a6
Keep p5.strands transpiler output valid for comma-joined expressions
harshiltewari2004 84645db
Declare hook intermediate variable before the .begin() statement, fix…
harshiltewari2004 ed81af8
Use regular block comments for internal transpiler helpers
harshiltewari2004 4301789
Merge branch 'main' into fix-strands-comma-operator
davepagurek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I believe this is still finding the index of the statement that contains a hook
.begin(). If we are trying to splice inintermediateVarDecl, so I was wondering if there is a chance that now we're splicing it after it gets used if it happens to get used in the same statement in a different comma-separated expression. Looks like this was only added to handle loops and branches (see #8576), but does this run on everysetcall? e.g. would this affect something that callssetright after abeginin a comma-separated expression currently? If not I'm curious what the flow is, would be good to add in a comment to help future contributors understand.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.
Good catch, this was a real bug. With
hook.begin(), hook.set(x)in onestatement, the
.set()becomes an assignment to the intermediate variable,but the
letwas inserted after that statement, so it threw aReferenceError. Before this PR it didn't happen only because
.begin()wasn't found inside comma expressions, so the declaration went to the top.
On your question: the pass only runs for functions with a
.set()insideif/for, but once it runs it rewrites every
.set()on that hook, includingone next to
.begin().I now insert the declaration before the
.begin()statement instead ofafter, added a comment explaining the flow, and added a regression test for
this case.
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 there be issues if you had multiple cooks all in the same statement, chained with commas? would it be more robust to see if it's in a comma expression or not, splice it into that right before the begin if so, and splice a statement before the whole statement if not?