-
-
Notifications
You must be signed in to change notification settings - Fork 48
impr: Name on a bound fn #2070
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
base: main
Are you sure you want to change the base?
impr: Name on a bound fn #2070
Conversation
📊 Bundle Size Comparison
👀 Notable resultsStatic test results:No major changes. Dynamic test results:No major changes. 📋 All resultsClick to reveal the results table (325 entries).
If you wish to run a comparison for other, slower bundlers, run the 'Tree-shake test' from the GitHub Actions menu. |
|
pkg.pr.new packages benchmark commit |
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.
Pull request overview
This PR enhances the naming behavior of bound functions (functions created using .with()) in the TypeGPU framework. The changes enable bound functions to have distinct names while allowing proper resolution of slotted variants during code generation.
Changes:
- Added
withRenamedutility toResolutionCtxfor temporarily renaming items during resolution - Modified
setNameto acceptundefinedas a valid name value - Updated bound functions to inherit parent function names by default and be independently nameable
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/typegpu/tests/slot.test.ts | Added tests verifying that bound functions can have independent names and that these names are correctly used in code generation |
| packages/typegpu/src/shared/meta.ts | Modified setName signature to accept undefined as a valid name value, enabling name clearing |
| packages/typegpu/src/resolutionCtx.ts | Added withRenamed method for temporarily renaming items during resolution, integrated it into the resolution of provided items |
| packages/typegpu/src/core/slot/slotTypes.ts | Changed Providing.inner type from unknown to object for better type safety |
| packages/typegpu/src/core/function/tgpuFn.ts | Removed $getNameForward from bound functions, changed dualImpl name to undefined, added logic to inherit parent function name by default |
| packages/typegpu/src/core/function/dualImpl.ts | Modified to accept undefined as a valid name option, updated toString to handle undefined names |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Changes:
withRenamedtowgslGenerator.tsto allow naming slotted functions differently (since they are the same inner function resolved multiple times),setName(item, undefined)(so that an unnamed inner function can lose its temporary name after resolving a slotted variant),.withed) functions inherit the name of the parent function if present, and unnamed otherwise (so that they can be autonamed).