From c20919c5ee279cc8bc9a493a42dfd332df783ba3 Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Thu, 21 Aug 2025 16:27:34 +0200 Subject: [PATCH] [wgsl] update reserved list to latest CR --- naga/src/keywords/wgsl.rs | 69 +++---------------- naga/tests/naga/wgsl_errors.rs | 40 +++++------ .../tests/out/wgsl/glsl-expressions.frag.wgsl | 4 +- .../wgsl/glsl-global-constant-array.frag.wgsl | 4 +- 4 files changed, 34 insertions(+), 83 deletions(-) diff --git a/naga/src/keywords/wgsl.rs b/naga/src/keywords/wgsl.rs index 8ec0dd59c..00c3cef2c 100644 --- a/naga/src/keywords/wgsl.rs +++ b/naga/src/keywords/wgsl.rs @@ -7,60 +7,18 @@ Keywords for [WGSL][wgsl] (WebGPU Shading Language). use crate::proc::KeywordSet; use crate::racy_lock::RacyLock; -// https://gpuweb.github.io/gpuweb/wgsl/#keyword-summary -// last sync: https://github.com/gpuweb/gpuweb/blob/39f2321f547c8f0b7f473cf1d47fba30b1691303/wgsl/index.bs +// last sync: https://www.w3.org/TR/2025/CRD-WGSL-20250809/#keyword-summary pub const RESERVED: &[&str] = &[ - // Type-defining Keywords - "array", - "atomic", - "bool", - "f32", - "f16", - "i32", - "i64", - "mat2x2", - "mat2x3", - "mat2x4", - "mat3x2", - "mat3x3", - "mat3x4", - "mat4x2", - "mat4x3", - "mat4x4", - "ptr", - "sampler", - "sampler_comparison", - "texture_1d", - "texture_2d", - "texture_2d_array", - "texture_3d", - "texture_cube", - "texture_cube_array", - "texture_external", - "texture_multisampled_2d", - "texture_storage_1d", - "texture_storage_2d", - "texture_storage_2d_array", - "texture_storage_3d", - "texture_depth_2d", - "texture_depth_2d_array", - "texture_depth_cube", - "texture_depth_cube_array", - "texture_depth_multisampled_2d", - "u32", - "u64", - "vec2", - "vec3", - "vec4", - // Other Keywords + // Keywords "alias", - "bitcast", "break", "case", "const", + "const_assert", "continue", "continuing", "default", + "diagnostic", "discard", "else", "enable", @@ -71,20 +29,14 @@ pub const RESERVED: &[&str] = &[ "let", "loop", "override", + "requires", "return", - "static_assert", "struct", "switch", "true", - "type", "var", "while", - // Reserved Words - "CompileShader", - "ComputeShader", - "DomainShader", - "GeometryShader", - "Hullshader", + // Reserved "NULL", "Self", "abstract", @@ -99,7 +51,6 @@ pub const RESERVED: &[&str] = &[ "auto", "await", "become", - "binding_array", "cast", "catch", "class", @@ -140,13 +91,11 @@ pub const RESERVED: &[&str] = &[ "get", "goto", "groupshared", - "handle", "highp", "impl", "implements", "import", "inline", - "inout", "instanceof", "interface", "layout", @@ -167,6 +116,8 @@ pub const RESERVED: &[&str] = &[ "noexcept", "noinline", "nointerpolation", + "non_coherent", + "noncoherent", "noperspective", "null", "nullptr", @@ -190,13 +141,12 @@ pub const RESERVED: &[&str] = &[ "regardless", "register", "reinterpret_cast", - "requires", + "require", "resource", "restrict", "self", "set", "shared", - "signed", "sizeof", "smooth", "snorm", @@ -213,6 +163,7 @@ pub const RESERVED: &[&str] = &[ "throw", "trait", "try", + "type", "typedef", "typeid", "typename", diff --git a/naga/tests/naga/wgsl_errors.rs b/naga/tests/naga/wgsl_errors.rs index dfc724056..8412faffd 100644 --- a/naga/tests/naga/wgsl_errors.rs +++ b/naga/tests/naga/wgsl_errors.rs @@ -736,13 +736,13 @@ fn reserved_keyword() { // global var check( r#" - var bool: bool = true; + var case: bool = true; "#, - r###"error: name `bool` is a reserved keyword + r###"error: name `case` is a reserved keyword ┌─ wgsl:2:17 │ -2 │ var bool: bool = true; - │ ^^^^ definition of `bool` +2 │ var case: bool = true; + │ ^^^^ definition of `case` "###, ); @@ -768,14 +768,14 @@ fn reserved_keyword() { check( r#" fn foo() { - let atomic: f32 = 1.0; + let enable: f32 = 1.0; } "#, - r###"error: name `atomic` is a reserved keyword + r###"error: name `enable` is a reserved keyword ┌─ wgsl:3:21 │ -3 │ let atomic: f32 = 1.0; - │ ^^^^^^ definition of `atomic` +3 │ let enable: f32 = 1.0; + │ ^^^^^^ definition of `enable` "###, ); @@ -784,14 +784,14 @@ fn reserved_keyword() { check( r#" fn foo() { - var sampler: f32 = 1.0; + var default: f32 = 1.0; } "#, - r###"error: name `sampler` is a reserved keyword + r###"error: name `default` is a reserved keyword ┌─ wgsl:3:21 │ -3 │ var sampler: f32 = 1.0; - │ ^^^^^^^ definition of `sampler` +3 │ var default: f32 = 1.0; + │ ^^^^^^^ definition of `default` "###, ); @@ -813,13 +813,13 @@ fn reserved_keyword() { // struct check( r#" - struct array {} + struct override {} "#, - r###"error: name `array` is a reserved keyword + r###"error: name `override` is a reserved keyword ┌─ wgsl:2:20 │ -2 │ struct array {} - │ ^^^^^ definition of `array` +2 │ struct override {} + │ ^^^^^^^^ definition of `override` "###, ); @@ -827,13 +827,13 @@ fn reserved_keyword() { // struct member check( r#" - struct Foo { sampler: f32 } + struct Foo { switch: f32 } "#, - r###"error: name `sampler` is a reserved keyword + r###"error: name `switch` is a reserved keyword ┌─ wgsl:2:26 │ -2 │ struct Foo { sampler: f32 } - │ ^^^^^^^ definition of `sampler` +2 │ struct Foo { switch: f32 } + │ ^^^^^^ definition of `switch` "###, ); diff --git a/naga/tests/out/wgsl/glsl-expressions.frag.wgsl b/naga/tests/out/wgsl/glsl-expressions.frag.wgsl index 016207c30..a71036a97 100644 --- a/naga/tests/out/wgsl/glsl-expressions.frag.wgsl +++ b/naga/tests/out/wgsl/glsl-expressions.frag.wgsl @@ -7,7 +7,7 @@ struct a_buf { } struct TestStruct { - array_: array, 2>, + array: array, 2>, } struct FragmentOutput { @@ -402,7 +402,7 @@ fn indexConstantNonConstantIndex(i: i32) { i_1 = i; let _e2 = i_1; - let _e7 = local_5.array_[_e2]; + let _e7 = local_5.array[_e2]; a_26 = _e7; return; } diff --git a/naga/tests/out/wgsl/glsl-global-constant-array.frag.wgsl b/naga/tests/out/wgsl/glsl-global-constant-array.frag.wgsl index 6582dfc9e..2519e9f9b 100644 --- a/naga/tests/out/wgsl/glsl-global-constant-array.frag.wgsl +++ b/naga/tests/out/wgsl/glsl-global-constant-array.frag.wgsl @@ -1,7 +1,7 @@ -const array_: array = array(1f, 2f); +const array: array = array(1f, 2f); fn main_1() { - var local: array = array_; + var local: array = array; return; }