Skip to content

Conversation

@vietnguyen2358
Copy link

Resolves #7994
Addresses #7992

Changes:

  • Added auto-return behavior for shader hooks with matching input and return types, allows users to omit return inputs when modifying struct properties in place
  • Implemented type checking to ensure auto-return only applies to struct-returning hooks with a single parameter of matching type

PR Checklist

@welcome
Copy link

welcome bot commented Jan 5, 2026

🎉 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!

Copy link
Contributor

@davepagurek davepagurek left a comment

Choose a reason for hiding this comment

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

This looks great, thanks for making these changes and also adding tests!

Copy link
Contributor

@davepagurek davepagurek left a comment

Choose a reason for hiding this comment

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

oh actually it looks like the tests are failing:

 FAIL |unit-tests|  test/unit/visual/cases/webgl.js > WebGL > p5.strands > auto-return for shader hooks > auto-return works with getObjectInputs > matches expected screenshots
TypeError: Cannot read properties of undefined (reading 'position')
 ❯ p5.hookImplementation src/strands/strands_api.js:446:50
    444|             const expectedProp = expectedProperties[i];
    445|             const propName = expectedProp.name;
    446|             const receivedValue = effectiveReturn[propName];
       |                                                  ^
    447|             if (receivedValue === undefined) {
    448|               FES.userError('type error', `You've returned an incomple…
 ❯ eval src/strands/strands_transpiler.js:1078:39
 ❯ src/strands/strands_transpiler.js:1087:20
 ❯ p5.Shader.modify src/strands/p5.strands.js:114:9
 ❯ test/unit/visual/cases/webgl.js:965:48
 ❯ test/unit/visual/visualTest.js:432:13

Possibly the isStructType check is failing? Maybe try adding some logging and then run npm run test test/unit/visual/cases/webgl.js to see what the types are?

@vietnguyen2358
Copy link
Author

Sure, I will look into it.

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