-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed as duplicate of#7293
Type mismatch diagnostic suggests to append integer literal suffix to non-literal
const expressions#7226Bug
Copy link
Labels
area: naga front-endTranslation to Naga IRTranslation to Naga IRarea: validationIssues related to validation, diagnostics, and error handlingIssues related to validation, diagnostics, and error handlingkind: diagnosticsError message should be betterError message should be betternagaShader TranslatorShader Translatortype: bugSomething isn't workingSomething isn't working
Description
Repro steps
-
Run the following in Naga, i.e.,
cargo run -p naga ../in.wgsl:const my_unsigned_int: u32 = 1u; @compute @workgroup_size(1, 1, 1) fn main() { let my_signed_int: i32 = 1i; switch (my_signed_int) { case my_unsigned_int: { break; } } }
Observe that the following error message is returned:
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.37s
Running `target\debug\naga.exe ../in.wgsl`
Could not parse WGSL:
error: invalid switch value
┌─ ../in.wgsl:8:14
│
8 │ case my_unsigned_int: {
│ ^^^^^^^^^^^^^^^ expected signed integer
│
= note: remove the `u` suffix: `my_unsigned_in`
error: process didn't exit successfully: `target\debug\naga.exe ../in.wgsl` (exit code: 1)
Expected vs observed behavior
We definitely shouldn't suggest this unless the expression is a single literal. We might adjust it by suggesting a constructor, i.e., i32(…), instead when there is something more complicated than a single literal present.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area: naga front-endTranslation to Naga IRTranslation to Naga IRarea: validationIssues related to validation, diagnostics, and error handlingIssues related to validation, diagnostics, and error handlingkind: diagnosticsError message should be betterError message should be betternagaShader TranslatorShader Translatortype: bugSomething isn't workingSomething isn't working
Type
Projects
Status
Done