From e1952dc8cf8f5b62d00ce114e353c5390cc6c37a Mon Sep 17 00:00:00 2001 From: kaizhangNV <149626564+kaizhangNV@users.noreply.github.com> Date: Thu, 6 Mar 2025 22:38:28 -0600 Subject: Fix a bug in default ctor synthesizing (#6527) * Fix a bug in default ctor synthesizing - This is fix for the implementation bug, when a struct has explicit ctor we should not synthesize the default ctor anymore. - When invoke the synthesized ctor converted from initializer list, we should check if the struct is a c-style type if it struct has no synthesized ctor. In this case we should report error because it's invalid to use initializer list here. - The only exception is the unsized array, we still have to fall back to use the legacy initializer list logic to initialize the unsized array until we formalize a proper solution. - update test. --- .../interfaces/default-construct-conformance.slang | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'tests/language-feature/interfaces') diff --git a/tests/language-feature/interfaces/default-construct-conformance.slang b/tests/language-feature/interfaces/default-construct-conformance.slang index 4a6aed869..b68dc8a4c 100644 --- a/tests/language-feature/interfaces/default-construct-conformance.slang +++ b/tests/language-feature/interfaces/default-construct-conformance.slang @@ -33,6 +33,11 @@ struct TestAny : ITest value = v; } + __init() + { + value = 0; + } + uint getValue() { return value; } } @@ -183,4 +188,4 @@ void testMain(uint3 threadID: SV_DispatchThreadID) } expected[outputIdx++] = uint(-1); -} \ No newline at end of file +} -- cgit v1.2.3