diff --git a/naga/tests/in/wgsl/loop-continuing-block.wgsl b/naga/tests/in/wgsl/loop-continuing-block.wgsl index 7aa30b0fc..c5d0b003e 100644 --- a/naga/tests/in/wgsl/loop-continuing-block.wgsl +++ b/naga/tests/in/wgsl/loop-continuing-block.wgsl @@ -136,6 +136,19 @@ fn break_if_uses_continuing() { } } +// Name collision between the loop body and the enclosing scope. +fn name_reuse() { + var a: f32 = 0.0; + loop { + var a: i32 = 1; + a += 1; + continuing { + break if a == 2; + } + } + var b = cos(a); +} + @compute @workgroup_size(1) fn main() { named(); @@ -146,4 +159,5 @@ fn main() { restricted_image_load(); call_result_as_index(); break_if_uses_continuing(); + name_reuse(); } diff --git a/naga/tests/out/msl/wgsl-loop-continuing-block.metal b/naga/tests/out/msl/wgsl-loop-continuing-block.metal index f31d2fc82..c05ef4ca0 100644 --- a/naga/tests/out/msl/wgsl-loop-continuing-block.metal +++ b/naga/tests/out/msl/wgsl-loop-continuing-block.metal @@ -228,6 +228,32 @@ void break_if_uses_continuing( return; } +void name_reuse( +) { + float a_4 = 0.0; + int a_5 = {}; + float b = {}; + uint2 loop_bound_9 = uint2(4294967295u); + bool loop_init_9 = true; + while(true) { + if (metal::all(loop_bound_9 == uint2(0u))) { break; } + loop_bound_9 -= uint2(loop_bound_9.y == 0u, 1u); + if (!loop_init_9) { + int _e7 = a_5; + if (_e7 == 2) { + break; + } + } + loop_init_9 = false; + a_5 = 1; + int _e4 = a_5; + a_5 = as_type(as_type(_e4) + as_type(1)); + } + float _e10 = a_4; + b = metal::cos(_e10); + return; +} + kernel void main_( metal::texture2d tex [[user(fake0)]] , device metal::float2 const& v0_ [[user(fake0)]] @@ -241,5 +267,6 @@ kernel void main_( restricted_image_load(tex); call_result_as_index(v0_); break_if_uses_continuing(counter); + name_reuse(); return; }