Merged
Conversation
|
pkg.pr.new packages benchmark commit |
There was a problem hiding this comment.
Pull request overview
This PR fixes collisions with WGSL builtin functions by adding them to the name registry's validation system. The key changes include moving struct property validation from the resolution phase to struct creation time and ensuring that user-defined functions/variables that collide with builtins are automatically renamed with numeric suffixes.
- Added a comprehensive list of WGSL builtin functions to the name registry
- Split identifier validation into two functions: one for general identifiers (checks builtins) and one for struct properties (allows builtins)
- Moved struct property validation from resolution to creation time for earlier error detection
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/typegpu/src/nameRegistry.ts | Added builtins set with all WGSL builtin functions, split validation into isValidIdentifier (checks builtins) and isValidProp (only checks reserved words), updated constructor to include builtins in used names |
| packages/typegpu/src/data/struct.ts | Moved property validation from resolution to struct creation, now validates property names using isValidProp at construction time |
| packages/typegpu/src/core/resolve/resolveData.ts | Removed struct property validation logic that was moved to struct creation |
| packages/typegpu/tests/struct.test.ts | Added tests for struct property validation (whitespace, reserved words) and test confirming builtin names are allowed as struct properties |
| packages/typegpu/tests/tgsl/nameClashes.test.ts | Added test verifying that user-defined functions named after builtins get renamed with numeric suffixes |
| packages/typegpu/tests/tgsl/wgslGenerator.test.ts | Removed struct property validation tests (moved to struct.test.ts) |
| packages/typegpu/tests/*.test.ts (multiple test files) | Updated test snapshots to reflect automatic renaming of identifiers that collide with builtins (e.g., ceil → ceil_1, sign → sign_1, log2 → log2_1, etc.) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Changes:
makeValidchecks (not used for prop naming).I also created an issue for cleaning up the
nameRegistry.ts(#2001).