[wgsl-in] Report concrete type mismatches in WGSL terms - #9973
Open
emilk wants to merge 2 commits into
Open
Conversation
`try_automatic_conversions` passed concrete values through untouched,
deliberately leaving the type error to the IR validator. But the
validator can only name operands by handle index, and prints handles from
different arenas identically, so a `return` mismatch read:
The `return` expression Some([1]) does not match the declared return type Some([1])
where one `[1]` is an expression and the other a type. Function call
arguments were equally opaque, and a composite constructor with a
wrong-typed component became "Composing 0's component type is not
expected".
The reason for the punt was message quality: reporting a plain mismatch
as a failed automatic conversion would mislead. So report a type
mismatch instead. Every caller of `try_automatic_conversions` now gets a
diagnostic with spans and WGSL type names, and no future caller can
forget to check.
`var`/`let` initializers keep their existing wording by mapping the new
error, which also makes their follow-up `compare_types` check redundant.
Fixes gfx-rs#7419.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
emilk
force-pushed
the
emilk/wgsl-type-mismatch-error
branch
from
July 30, 2026 10:51
b3a0fa4 to
8991201
Compare
8 tasks
emilk
commented
Jul 30, 2026
emilk
marked this pull request as ready for review
July 30, 2026 12:18
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.
Connections
Description
try_automatic_conversionspassed concrete values through untouched, deliberately leaving the type error to the IR validator. But the validator can only name operands by handle index, and prints handles from different arenas identically, so areturnmismatch readThe `return` expression Some([1]) does not match the declared return type Some([1])— where one[1]is an expression and the other a type.The punt was about message quality: calling a plain mismatch a failed automatic conversion would mislead. So report a type mismatch instead. That single choke point covers
return, call arguments, composite constructors andvar/letinitializers, and no future caller can forget to check.Testing
New/updated
checksnapshots inwgsl_errors.rs; threecheck_validation!tests are now parse errors. Also parsed every.wgslin the repo (nothing newly rejected) and regenerated allTargets::IRsnapshots (no diff).Squash or Rebase?
Rebase — single commit.
Checklist
wgpumay be affected behaviorally.CHANGELOG.mdentries for the user-facing effects of this change are present.🤖 Generated with Claude Code