summaryrefslogtreecommitdiffstats
path: root/tests/diagnostics/overload-ambiguous.slang
blob: 0c8f7bd21666ae704323510ff6a2030998a91df0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// https://github.com/shader-slang/slang/issues/4476

//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK):
RWStructuredBuffer<uint> outputBuffer;

namespace A1
{
    uint func()
    {
        return 1u;
    }

    namespace A2
    {
        uint func()
        {
            return 2u;
        }
    }
}
namespace B1
{
    uint func()
    {
        return 4u;
    }
}

[numthreads(1, 1, 1)]
[shader("compute")]
void computeMain(uint3 threadID: SV_DispatchThreadID)
{
    using namespace A1;
    using namespace A1::A2;
    using namespace B1;
    using namespace C1;

    // Only A1::func() and B1::func() will cause ambiguity because the distance from
    // the reference site to those two functions declaration are the same.
    outputBuffer[0] = func();
    // CHECK-NOT: {{.*}}A2::func() -> uint
    // CHECK: ambiguous call to 'func' with arguments of type ()
    // CHECK: candidate: func B1::func() -> uint
    // CHECK: candidate: func A1::func() -> uint
}