yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

kaizhangNVLower the priority of looking up the rank of scope (#5065)3240799c0

master
956 B45 linesraw
1// https://github.com/shader-slang/slang/issues/4476
2
3//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK):
4RWStructuredBuffer<uint> outputBuffer;
5
6namespace A1
7{
8    uint func()
9    {
10        return 1u;
11    }
12
13    namespace A2
14    {
15        uint func()
16        {
17            return 2u;
18        }
19    }
20}
21namespace B1
22{
23    uint func()
24    {
25        return 4u;
26    }
27}
28
29[numthreads(1, 1, 1)]
30[shader("compute")]
31void computeMain(uint3 threadID: SV_DispatchThreadID)
32{
33    using namespace A1;
34    using namespace A1::A2;
35    using namespace B1;
36    using namespace C1;
37
38    // Only A1::func() and B1::func() will cause ambiguity because the distance from
39    // the reference site to those two functions declaration are the same.
40    outputBuffer[0] = func();
41    // CHECK-NOT: {{.*}}A2::func() -> uint
42    // CHECK: ambiguous call to 'func' with arguments of type ()
43    // CHECK: candidate: func B1::func() -> uint
44    // CHECK: candidate: func A1::func() -> uint
45}