Skip to content

fix: Collisions with builtins#2002

Merged
aleksanderkatan merged 6 commits intomainfrom
fix/collisions-with-builtins
Dec 23, 2025
Merged

fix: Collisions with builtins#2002
aleksanderkatan merged 6 commits intomainfrom
fix/collisions-with-builtins

Conversation

@aleksanderkatan
Copy link
Contributor

@aleksanderkatan aleksanderkatan commented Dec 23, 2025

Changes:

  • move struct prop validation from resolution to struct creation,
  • add builtins to makeValid checks (not used for prop naming).

I also created an issue for cleaning up the nameRegistry.ts (#2001).

@github-actions
Copy link

github-actions bot commented Dec 23, 2025

pkg.pr.new

packages
Ready to be installed by your favorite package manager ⬇️

https://pkg.pr.new/software-mansion/TypeGPU/typegpu@1e1c884e6488c30648c397c2f1a88490ed2c04f8
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/noise@1e1c884e6488c30648c397c2f1a88490ed2c04f8
https://pkg.pr.new/software-mansion/TypeGPU/unplugin-typegpu@1e1c884e6488c30648c397c2f1a88490ed2c04f8

benchmark
view benchmark

commit
view commit

Copy link

Copilot AI left a 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 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., ceilceil_1, signsign_1, log2log2_1, etc.)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@aleksanderkatan aleksanderkatan marked this pull request as ready for review December 23, 2025 14:01
Copy link
Collaborator

@iwoplaza iwoplaza left a comment

Choose a reason for hiding this comment

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

Great fix! 🩹🍓

Copy link
Collaborator

@cieplypolar cieplypolar left a comment

Choose a reason for hiding this comment

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

Looks good 🎄

@aleksanderkatan aleksanderkatan merged commit 1d2b8ea into main Dec 23, 2025
9 checks passed
@aleksanderkatan aleksanderkatan deleted the fix/collisions-with-builtins branch January 12, 2026 09:51
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.

4 participants