Skip to content
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

Differentiate between i32 and u32 in switch #2269

Merged
merged 3 commits into from
Mar 10, 2023
Merged

Conversation

evahop
Copy link
Contributor

@evahop evahop commented Mar 8, 2023

Fixes #1960.

Updated all instances of SwitchValue::Integer to include uints.

Renamed select_cases to switch_values since it did not appear to be used for anything other than switch values.

Added a check to validate all cases had similar types. That's just how I interpreted this bit from the spec.

Added a duplicate SwitchValue enum to validation since I wasn't sure if adding additional derives to lib was appropriate or not. This adds a tiny bit of redundancy that I can remove if needed.

@codecov-commenter
Copy link

codecov-commenter commented Mar 8, 2023

Codecov Report

Merging #2269 (02249d3) into master (00be08e) will decrease coverage by 0.02%.
The diff coverage is 58.42%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##           master    #2269      +/-   ##
==========================================
- Coverage   82.05%   82.04%   -0.02%     
==========================================
  Files          80       80              
  Lines       43241    43250       +9     
==========================================
+ Hits        35481    35483       +2     
- Misses       7760     7767       +7     
Impacted Files Coverage Δ
src/back/dot/mod.rs 46.16% <0.00%> (ø)
src/front/spv/function.rs 67.32% <0.00%> (ø)
src/lib.rs 33.88% <ø> (ø)
src/valid/function.rs 73.18% <38.46%> (-0.88%) ⬇️
src/front/glsl/parser/functions.rs 85.89% <45.00%> (-0.07%) ⬇️
src/back/glsl/mod.rs 86.16% <100.00%> (-0.02%) ⬇️
src/back/hlsl/writer.rs 91.12% <100.00%> (-0.01%) ⬇️
src/back/msl/writer.rs 90.92% <100.00%> (-0.01%) ⬇️
src/back/spv/block.rs 91.33% <100.00%> (+0.01%) ⬆️
src/back/wgsl/writer.rs 91.64% <100.00%> (-0.07%) ⬇️
... and 6 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Member

@teoxoy teoxoy 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 good; thanks for the PR!

Added a duplicate SwitchValue enum to validation since I wasn't sure if adding additional derives to lib was appropriate or not. This adds a tiny bit of redundancy that I can remove if needed.

I think it should be fine to just derive Copy, Eq, Hash, PartialEq on the original enum.

@evahop evahop requested a review from teoxoy March 10, 2023 16:30
@teoxoy teoxoy merged commit 8a72b7a into gfx-rs:master Mar 10, 2023
kvark pushed a commit to kvark/naga that referenced this pull request Mar 18, 2023
* Differentiate between i32 and u32 in switch

* Use similar wording to other error messages

* Remove duplicate enum
@evahop evahop deleted the switch-u32 branch September 28, 2023 14:35
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.

[glsl-out] [wgsl-out] Incorrect translation of unsigned switch cases as signed
3 participants