summaryrefslogtreecommitdiffstats
path: root/tests/diagnostics
diff options
context:
space:
mode:
authorkaizhangNV <149626564+kaizhangNV@users.noreply.github.com>2025-05-22 21:29:06 -0500
committerGitHub <noreply@github.com>2025-05-22 19:29:06 -0700
commit3072cfea95aad2a9ddab0f517c8f18f634442a27 (patch)
tree966c019c35604b0f457caec02c9619feddbf2665 /tests/diagnostics
parent2d34409f2e72673ac9fd766eaeaa75f60882e7ca (diff)
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.
Diffstat (limited to 'tests/diagnostics')
-rw-r--r--tests/diagnostics/extension-full-name.slang.expected25
-rw-r--r--tests/diagnostics/mismatching-types.slang.expected1
2 files changed, 14 insertions, 12 deletions
diff --git a/tests/diagnostics/extension-full-name.slang.expected b/tests/diagnostics/extension-full-name.slang.expected
index 8001298c1..72eef77e3 100644
--- a/tests/diagnostics/extension-full-name.slang.expected
+++ b/tests/diagnostics/extension-full-name.slang.expected
@@ -1,39 +1,40 @@
result code = -1
standard error = {
-tests/diagnostics/extension-full-name.slang(184): error 30019: expected an expression of type 'GenericType<half>.State', got 'int'
+tests/diagnostics/extension-full-name.slang(185): error 30019: expected an expression of type 'GenericType<half>.State', got 'int'
state1 = 0; // Error: expected expr of type 'GenericType<half>.State', got 'int'
^
-tests/diagnostics/extension-full-name.slang(185): error 30019: expected an expression of type 'GenericType<float>.InnerType.Options', got 'int'
+tests/diagnostics/extension-full-name.slang(186): error 30019: expected an expression of type 'GenericType<float>.InnerType.Options', got 'int'
options1 = 0; // Error: expected expr of type 'GenericType<float>.InnerType.Options', got 'int'
^
-tests/diagnostics/extension-full-name.slang(186): error 30019: expected an expression of type 'NonGenericType.Config', got 'int'
+tests/diagnostics/extension-full-name.slang(187): error 30019: expected an expression of type 'NonGenericType.Config', got 'int'
config1 = 0; // Error: expected expr of type 'NonGenericType.Config', got 'int'
^
-tests/diagnostics/extension-full-name.slang(187): error 30019: expected an expression of type 'Container.Nested.Settings', got 'int'
+tests/diagnostics/extension-full-name.slang(188): error 30019: expected an expression of type 'Container.Nested.Settings', got 'int'
settings1 = 0; // Error: expected expr of type 'Container.Nested.Settings', got 'int'
^
-tests/diagnostics/extension-full-name.slang(188): error 30019: expected an expression of type 'Container.Nested.DeepNested.Record', got 'int'
+tests/diagnostics/extension-full-name.slang(189): error 30019: expected an expression of type 'Container.Nested.DeepNested.Record', got 'int'
record1 = 0; // Error: expected expr of type 'Container.Nested.DeepNested.Record', got 'int'
^
-tests/diagnostics/extension-full-name.slang(196): error 30027: 'getOptions' is not a member of 'GenericType<int>.InnerType'.
+tests/diagnostics/extension-full-name.slang(189): note: explicit conversion from 'int' to 'Container.Nested.DeepNested.Record' is possible
+tests/diagnostics/extension-full-name.slang(197): error 30027: 'getOptions' is not a member of 'GenericType<int>.InnerType'.
intInner.getOptions(); // This won't compile as intInner doesn't have getOptions
^~~~~~~~~~
-tests/diagnostics/extension-full-name.slang(226): error 30019: expected an expression of type 'GenericType<float>.InnerType.Options', got 'GenericType<half>.State'
+tests/diagnostics/extension-full-name.slang(227): error 30019: expected an expression of type 'GenericType<float>.InnerType.Options', got 'GenericType<half>.State'
.createState(); // Error: expected expr of type 'GenericType<float>.InnerType.Options',
^
-tests/diagnostics/extension-full-name.slang(228): error 30019: expected an expression of type 'GenericType<half>.State', got 'NonGenericType.Config'
+tests/diagnostics/extension-full-name.slang(229): error 30019: expected an expression of type 'GenericType<half>.State', got 'NonGenericType.Config'
state1 = nonGenType.createConfig(); // Error: expected expr of type 'GenericType<half>.State',
^
-tests/diagnostics/extension-full-name.slang(230): error 30019: expected an expression of type 'NonGenericType.Config', got 'Container.Nested.Settings'
+tests/diagnostics/extension-full-name.slang(231): error 30019: expected an expression of type 'NonGenericType.Config', got 'Container.Nested.Settings'
config1 = nested.createSettings(); // Error: expected expr of type 'NonGenericType.Config', got
^
-tests/diagnostics/extension-full-name.slang(304): error 30019: expected an expression of type 'Bar[3].DataStats', got 'int'
+tests/diagnostics/extension-full-name.slang(305): error 30019: expected an expression of type 'Bar[3].DataStats', got 'int'
barStats = 0; // Error: expected expr of type 'Bar[3].DataStats', got 'int'
^
-tests/diagnostics/extension-full-name.slang(312): error 30019: expected an expression of type 'Bar[2].DataStats', got 'Bar[3].DataStats'
+tests/diagnostics/extension-full-name.slang(313): error 30019: expected an expression of type 'Bar[2].DataStats', got 'Bar[3].DataStats'
bar2Stats = barArray.computeStats(); // Error: expected expr of type 'Bar[2].DataStats', got 'Bar[3].DataStats'
^
-tests/diagnostics/extension-full-name.slang(355): error 30019: expected an expression of type 'SimpleBase.NamedConfig', got 'int'
+tests/diagnostics/extension-full-name.slang(356): error 30019: expected an expression of type 'SimpleBase.NamedConfig', got 'int'
config = 0; // Error: expected expr of type 'SimpleBase.NamedConfig', got 'int'
^
}
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<int>', got 'int'
c.i = 0;
^
+tests/diagnostics/mismatching-types.slang(66): note: explicit conversion from 'int' to 'NonGenericOuter.GenericInner<int>' is possible
tests/diagnostics/mismatching-types.slang(68): error 30019: expected an expression of type 'NonGenericOuter.GenericInner<int>', got 'NonGenericOuter.GenericInner<float>'
c.i = c.f;
^