Skip to content

feat: add friendly error for cross-hook property access (#8813)#8862

Merged
davepagurek merged 3 commits into
processing:dev-2.0from
BHARATH0153:fix/cross-hook-fes-error
Jun 2, 2026
Merged

feat: add friendly error for cross-hook property access (#8813)#8862
davepagurek merged 3 commits into
processing:dev-2.0from
BHARATH0153:fix/cross-hook-fes-error

Conversation

@BHARATH0153

Copy link
Copy Markdown

Resolves #8813

Changes

Adds a friendly error when accessing one hook's struct properties from within another hook's begin()/end() block in the flat strands API. Previously this gave a cryptic TypeError because struct property getters were only defined during setupHook().

After this PR, the same code gives a clear error with a suggestion to use sharedVec3() or sharedFloat() for cross-hook data sharing.

Screenshots of the change

N/A — error-message change only.

PR Checklist

)

When accessing one hook's struct properties from within another
hook's begin/end block, show a helpful error suggesting sharedVec3
or sharedFloat instead of the cryptic undefined TypeError.
@welcome

welcome Bot commented Jun 2, 2026

Copy link
Copy Markdown

🎉 Thanks for opening this pull request! For guidance on contributing, check out our contributor guidelines and other resources for contributors!
🤔 Please ensure that your PR links to an issue, which has been approved for work by a maintainer; otherwise, there might already be someone working on it, or still ongoing discussion about implementation. You are welcome to join the discussion in an Issue if you're not sure!
🌸 Once your PR is merged, be sure to add yourself to the list of contributors on the readme page !

Thank You!

@davepagurek davepagurek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this, the approach looks good! Do you think we can add a unit test to make sure the error behaviour continues working into the future?

Comment thread src/strands/strands_api.js Outdated
@p5-bot

p5-bot Bot commented Jun 2, 2026

Copy link
Copy Markdown

Continuous Release

CDN link

Published Packages

Commit hash: 6149cf3

Previous deployments

f458618


This is an automated message.

BHARATH0153 added 2 commits June 2, 2026 18:43
The scope error message now uses the display name alias (e.g. worldInputs)
instead of the internal shader function name (e.g. getWorldInputs).
This matches the primary API that users interact with via begin()/end().

Also added a unit test verifying the error uses the unprefixed name.

@davepagurek davepagurek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@davepagurek davepagurek merged commit 6759f35 into processing:dev-2.0 Jun 2, 2026
5 checks passed
@davepagurek

Copy link
Copy Markdown
Contributor

@all-contributors please add @BHARATH0153 for code

@allcontributors

Copy link
Copy Markdown
Contributor

@davepagurek

I've put up a pull request to add @BHARATH0153! 🎉

vamshi567bh pushed a commit to vamshi567bh/p5.js that referenced this pull request Jun 20, 2026
…s-error

feat: add friendly error for cross-hook property access (processing#8813)
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

Successfully merging this pull request may close these issues.

2 participants