From 497033d937792e0008d70dfba3676de06ef9eb15 Mon Sep 17 00:00:00 2001 From: kaizhangNV <149626564+kaizhangNV@users.noreply.github.com> Date: Fri, 13 Jun 2025 11:09:03 -0500 Subject: Fix issue that struct with member is not its Differential type (#7434) Close #6176. If the struct has a `no_diff` member, it should not be its Differential type. We miss this check. --- .../differential-type-syntheize-diagnostics.slang | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tests/autodiff/differential-type-syntheize-diagnostics.slang (limited to 'tests') diff --git a/tests/autodiff/differential-type-syntheize-diagnostics.slang b/tests/autodiff/differential-type-syntheize-diagnostics.slang new file mode 100644 index 000000000..f8663a5a1 --- /dev/null +++ b/tests/autodiff/differential-type-syntheize-diagnostics.slang @@ -0,0 +1,30 @@ +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): + +struct PartlyDiffable : IDifferentiable +{ + no_diff float noDiffMember; + float diffMember; +} + +float func(PartlyDiffable.Differential x) +{ + // CHECK: ([[# @LINE+1]]): error 30027: 'noDiffMember' is not a member of 'PartlyDiffable.Differential'. + return x.noDiffMember; +} + +float func1(PartlyDiffable.Differential x) +{ + // CHECK-NOT: ([[# @LINE+1]]): error 30027: 'diffMember. + return x.diffMember; +} + +RWStructuredBuffer out; + +[shader("compute")] +void compute() +{ + // CHECK: ([[# @LINE+1]]): error 39999: no overload for 'Differential' applicable to arguments of type (float, float) + var diff = PartlyDiffable.Differential(1.0f, 2.0f); + out[0] = func(diff); + out[1] = func1(diff); +} -- cgit v1.2.3