blob: 82f33ef8d32054f87aef5c6ba836c9051ebdbb5c (
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
//TEST:SIMPLE(filecheck=CHECK_2026): -stage compute -entry computeMain -lang slang -std 2026
//TEST:SIMPLE(filecheck=CHECK_2025_OR_EXP): -stage compute -entry computeMain
//TEST:SIMPLE(filecheck=CHECK_2025_OR_EXP): -stage compute -entry computeMain -lang slang -std 2026 -enable-experimental-dynamic-dispatch
// Validate AST side of `dyn` keyword use-cases
// `experimental-dynamic-dispatch` and `-lang 2025` have fewer restrictions
//
// CHECK_2025_OR_EXP-NOT: error 33072
// CHECK_2025_OR_EXP-NOT: error 33073
// CHECK_2025_OR_EXP-NOT: error 33074
// CHECK_2025_OR_EXP-NOT: error 33075
// CHECK_2025_OR_EXP-NOT: error 33076
// CHECK_2025_OR_EXP-NOT: error 33077
// CHECK_2025_OR_EXP-NOT: error 33078
// CHECK_2025_OR_EXP-NOT: error 33082
/////////////////////////////////////////////////////
// `dyn` interfaces are not allowed to be generics
// CHECK_2026-DAG: error 33072
dyn interface interface1<T>
{
static const int member;
};
// `dyn` interfaces must not define any associated types.
// CHECK_2026-DAG: error 33073
interface IBase1
{
};
dyn interface interface2
{
associatedtype IBase1;
};
// `dyn` interfaces must not define any generic methods.
// CHECK_2026-DAG: error 33074
dyn interface interface3
{
T genericFunc<T : IArithmetic>(T val)
{
return val*(T)2;
}
};
// `dyn` interfaces must not define any mutating methods
// CHECK_2026-DAG: error 33075
dyn interface interface4
{
[mutating]
void mutate(int val);
};
// `dyn` interfaces cannot inherit from any interfaces that are not dyn.
// CHECK_2026-DAG: error 33077
interface IBase2
{
};
dyn interface interface5 : IBase2
{
int myFunc(int val)
{
return val*2;
}
};
dyn interface IBase3
{
};
dyn interface interface6 : IBase3
{
int myFunc(int val)
{
return val*2;
}
};
// `dyn` interfaces cannot contain any function requirements that are marked as [Differentiable].
// CHECK_2026-DAG: error 33076
dyn interface interface7
{
[Differentiable]
int myFunc(int val)
{
return val*2;
}
};
// The type which is conforming to a dyn (myType in interface myType : IBase) cannot be generic.
// CHECK_2026-DAG: error 33082
// CHECK_2026-DAG: error 33082
dyn interface IBase4
{
int doMath(int val);
};
struct genericStruct1<T : IArithmetic> : IBase4
{
T a;
int doMath(int v)
{
return v * (int)2;
}
};
interface genericInterface1<T : IArithmetic> : IBase4
{
T doMath(T v)
{
return v * (T)3;
}
};
// Extensions that make a type conform/inherit to dyn interfaces are not allowed.
// CHECK_2026-DAG: error 33078
dyn interface IBase5
{
};
interface interface9
{
};
extension<T:interface9> T : IBase5
{
int doMath()
{
return 5;
}
};
// Type conforming to `dyn` interface must be an ordinary data type, meaning that it cannot contain any fields that are opaque or non-copyable or unsized.
// CHECK_2026-DAG: error 33079
// CHECK_2026-DAG: error 33080
// CHECK_2026-DAG: error 33081
// CHECK_2026-DAG: error 33081
// CHECK_2025_OR_EXP-DAG: error 33079
// CHECK_2025_OR_EXP-DAG: error 33080
// CHECK_2025_OR_EXP-DAG: error 33081
struct structWithUnsized : IBase6
{
int v[];
};
struct structWithOpaque : IBase6
{
Texture2D<float> v;
};
dyn interface IBase6
{
};
[__NonCopyableType]
struct NonCopyableStruct1
{
float v;
}
struct structWithNonCopyable1 : IBase6
{
NonCopyableStruct1 v;
};
[__NonCopyableType]
struct NonCopyableStruct2<T : IArithmetic>
{
T v;
}
struct structWithNonCopyable2 : IBase6
{
NonCopyableStruct2<int> v;
};
// `dyn` interfaces cannot contain any methods that has a `some` IFoo return type, or has any `some` IFoo parameters.
// TODO-INTERFACE-QUALIFIERS-ADDITION-OF-SOME
//
RWStructuredBuffer<int> outputBuffer;
[numthreads(4, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
outputBuffer[0] = 0;
}
|