summaryrefslogtreecommitdiffstats
path: root/tests/language-feature
diff options
context:
space:
mode:
authorJay Kwak <82421531+jkwak-work@users.noreply.github.com>2025-07-24 16:47:21 -0700
committerGitHub <noreply@github.com>2025-07-24 23:47:21 +0000
commit138efb9c25aadd319db6e6300a263574d90e3391 (patch)
tree505bedcf8272be97184c7d03a54ada38c33e6157 /tests/language-feature
parenta9d1cc5daaf2cf72be88f7ebf4a2e3c3da68abc9 (diff)
Avoid early specialization for witness tables in SimplifyIR (#7636)
* Avoid early specialization for witness tables in SimplifyIR Prevents SimplifyIR from prematurely specializing witness tables before the main specialization pass. Witness tables are hoistable immutable objects that must maintain consistent signatures to avoid incorrect deduplication. SimplifyIR was incorrectly transforming expressions like "witness_table_t(%IFoo)(specialize(%7, %GenericValue4))" into "witness_table_t(%IFoo)(%Foo)" even when %GenericValue4 was unused. Fixes #7233 * Add a missing test file
Diffstat (limited to 'tests/language-feature')
-rw-r--r--tests/language-feature/interfaces/generic-value-parameter-via-interface.slang44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/language-feature/interfaces/generic-value-parameter-via-interface.slang b/tests/language-feature/interfaces/generic-value-parameter-via-interface.slang
new file mode 100644
index 000000000..abc1131e8
--- /dev/null
+++ b/tests/language-feature/interfaces/generic-value-parameter-via-interface.slang
@@ -0,0 +1,44 @@
+//TEST:INTERPRET(filecheck=CHECK):
+
+interface IFoo
+{
+ void test();
+};
+
+struct Foo<let GenericValue : uint> : IFoo
+{
+ void test()
+ {
+ printf("GenericValue=%d, value=%d\n", GenericValue, value);
+ }
+
+ uint value;
+};
+
+void testInterfaceAsParameter(IFoo foo)
+{
+ foo.test();
+}
+
+void testInterfaceAsGeneric<T:IFoo>(T foo)
+{
+ foo.test();
+}
+
+void main()
+{
+ // CHECK-COUNT-2:GenericValue=0, value=0
+ Foo<0> foo0 = {0};
+ testInterfaceAsParameter(foo0);
+ testInterfaceAsGeneric(foo0);
+
+ // CHECK-COUNT-2:GenericValue=1, value=1
+ Foo<1> foo1 = {1};
+ testInterfaceAsParameter(foo1);
+ testInterfaceAsGeneric(foo1);
+
+ // CHECK-COUNT-2:GenericValue=2, value=2
+ Foo<2> foo2 = {2};
+ testInterfaceAsParameter(foo2);
+ testInterfaceAsGeneric(foo2);
+}