From 3072cfea95aad2a9ddab0f517c8f18f634442a27 Mon Sep 17 00:00:00 2001 From: kaizhangNV <149626564+kaizhangNV@users.noreply.github.com> Date: Thu, 22 May 2025 21:29:06 -0500 Subject: Implement default initializer list for C-Style type member (#7079) * Implement default initializer list for C-Style type member Close #6189. Previsouly, for the C-Style member in a struct, if it doesn't have any initialize expression, when we synthesize the ctor, we will not associate the default value for the parameter corresponding to that member. This bring some trouble that existing slang users has to add '= {}' to every struct fields in order to make all the parameters in the synthesized ctor having a default value, so people can still use `Struct a = {}` to create a struct. To make this use case convenience, we will automatically associated a '= {}' as the default value for this case. This PR also add support for empty initializing link-time sized vector/matrix by "= {}". In addition, this PR also fix a bug in auto diff where we should not report error when proccessing transpose on an empty struct. --- tests/diagnostics/mismatching-types.slang.expected | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/diagnostics/mismatching-types.slang.expected') diff --git a/tests/diagnostics/mismatching-types.slang.expected b/tests/diagnostics/mismatching-types.slang.expected index a706e30e6..e247d16a8 100644 --- a/tests/diagnostics/mismatching-types.slang.expected +++ b/tests/diagnostics/mismatching-types.slang.expected @@ -20,6 +20,7 @@ tests/diagnostics/mismatching-types.slang(63): error 30019: expected an expressi tests/diagnostics/mismatching-types.slang(66): error 30019: expected an expression of type 'NonGenericOuter.GenericInner', got 'int' c.i = 0; ^ +tests/diagnostics/mismatching-types.slang(66): note: explicit conversion from 'int' to 'NonGenericOuter.GenericInner' is possible tests/diagnostics/mismatching-types.slang(68): error 30019: expected an expression of type 'NonGenericOuter.GenericInner', got 'NonGenericOuter.GenericInner' c.i = c.f; ^ -- cgit v1.2.3