summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorCopilot <198982749+Copilot@users.noreply.github.com>2025-07-09 16:05:22 +0000
committerGitHub <noreply@github.com>2025-07-09 16:05:22 +0000
commite40ddc6efb275a753a46f8c8bcc420801668c931 (patch)
treee86d6dfb28dc2ec5dc6e6baff22ac94a7739f3f0 /tests
parenta670bafc121c20168624f70a388dbe8556402c7f (diff)
Fix internal error when a generic in an extension is unused (#7665)
* Initial plan * Add diagnostic for unreferenced generic parameters in extensions Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Use GenericTypeParamDeclBase and eliminate intermediate list Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Update test to use filecheck format for better verification Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Update extension validation to use getMembersOfType for better constraint collection Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Add temporary workaround for inheritance constraints but issue persists Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix inheritance constraint validation by moving to SemanticsDeclConformancesVisitor Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix inheritance constraint validation by removing inheritance declaration checks Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Move extension generic parameter validation back to SemanticsDeclBasesVisitor Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix test. * format code (#7671) Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> * Fix and update. * Refine fix. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> Co-authored-by: Yong He <yonghe@outlook.com> Co-authored-by: slangbot <ellieh+slangbot@nvidia.com> Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/diagnostics/extension-unreferenced-generic-param.slang26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/diagnostics/extension-unreferenced-generic-param.slang b/tests/diagnostics/extension-unreferenced-generic-param.slang
new file mode 100644
index 000000000..80aba4adb
--- /dev/null
+++ b/tests/diagnostics/extension-unreferenced-generic-param.slang
@@ -0,0 +1,26 @@
+//TEST:SIMPLE(filecheck=CHECK): -target spirv
+// Test unreferenced generic parameters in extensions
+
+// Error case 1: Simple unreferenced generic parameter
+// CHECK: ([[# @LINE+1]]): error 30855:
+extension<T> int
+{
+ void foo() {}
+}
+
+// Error case 2: Multiple generic parameters, some unused
+// CHECK: ([[# @LINE+1]]): error 30855:
+extension<T, U> vector<T, 3>
+{
+ void bar() {}
+}
+
+// Error case 3: Parameters only used in inheritance declaration should be errors
+interface IFooGeneric<S> {}
+struct MyType {}
+
+// CHECK: ([[# @LINE+1]]): error 30855:
+extension<S> MyType : IFooGeneric<S>
+{
+ void shouldFail() {}
+}