Read p5.strands callback params and body from the AST - #9188
Merged
perminder-17 merged 3 commits intoSep 20, 2026
Merged
Conversation
escodegen drops parentheses on a single arrow parameter, so the old regex
failed on param => { ... }. Use the parsed function node instead.
Fixes processing#9180
19 tasks
perminder-17
self-requested a review
September 20, 2026 01:24
Continuous ReleaseCDN linkPublished PackagesCommit hash: 941e748 Previous deploymentsThis is an automated message. |
perminder-17
approved these changes
Sep 20, 2026
perminder-17
left a comment
Collaborator
There was a problem hiding this comment.
Looks good to me! Thanks for your work on this @tsumon
Collaborator
|
@all-contributors please add @tsumon for code |
Contributor
|
I've put up a pull request to add @tsumon! 🎉 |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Resolves #9180
Changes:
buildStrandsCallbackused a regex on escodegen output that required a parenthesized parameter list. escodegen prints a single arrow parameter without parentheses, soparam => { ... }(and(param) => { ... }after codegen) threwCould not parse p5.strands function!.The callback source is wrapped in parentheses before parsing, so the function is the program's single expression. This change reads params and body from that AST node instead of the regex.
Added a regression test that passes the unparenthesized arrow form as source text so the case does not depend on how the test file itself is transformed.
function(param) {},() => {}, and({ p }) => {}still go through the same callback path.AI usage:
I used an AI assistant to explore the transpiler, draft the AST extraction, and add the regression test. I reviewed every line. The approach follows the discussion on #9180: add a failing test first, then read params and body from the AST because that regex has been brittle.
PR Checklist
npm run lintpasses on the two changed files