Skip to content

Commit ae10a6b

Browse files
committed
C#: Check that we get AST for struct that doesn't initialize all fields.
1 parent 3cd2024 commit ae10a6b

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

csharp/ql/test/library-tests/csharp11/PrintAst.expected

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,33 @@ Struct.cs:
694694
# 12| -1: [TypeMention] object
695695
# 13| 11: [Field] MyReadonlyString
696696
# 13| -1: [TypeMention] string
697+
StructDefault.cs:
698+
# 1| [Class] MyEmptyClass
699+
# 2| [Struct] StructDefaultValue
700+
# 4| 5: [Field] X
701+
# 4| -1: [TypeMention] int
702+
# 5| 6: [Field] Y
703+
# 5| -1: [TypeMention] int
704+
# 6| 7: [Field] Z
705+
# 6| -1: [TypeMention] MyEmptyClass
706+
# 8| 8: [InstanceConstructor] StructDefaultValue
707+
#-----| 2: (Parameters)
708+
# 8| 0: [Parameter] x
709+
# 8| -1: [TypeMention] int
710+
# 8| 1: [Parameter] inity
711+
# 8| -1: [TypeMention] bool
712+
# 9| 4: [BlockStmt] {...}
713+
# 10| 0: [ExprStmt] ...;
714+
# 10| 0: [AssignExpr] ... = ...
715+
# 10| 0: [FieldAccess] access to field X
716+
# 10| 1: [ParameterAccess] access to parameter x
717+
# 11| 1: [IfStmt] if (...) ...
718+
# 11| 0: [ParameterAccess] access to parameter inity
719+
# 11| 1: [BlockStmt] {...}
720+
# 11| 0: [ExprStmt] ...;
721+
# 11| 0: [AssignExpr] ... = ...
722+
# 11| 0: [FieldAccess] access to field Y
723+
# 11| 1: [IntLiteral] 1
697724
cil/class1.cs:
698725
# 4| [Class] Class1
699726
# 6| 5: [Method] Main
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
public class MyEmptyClass { }
2+
public struct StructDefaultValue
3+
{
4+
public int X;
5+
public int Y;
6+
public MyEmptyClass? Z;
7+
8+
public StructDefaultValue(int x, bool inity)
9+
{
10+
X = x;
11+
if (inity) { Y = 1; }
12+
}
13+
}

0 commit comments

Comments
 (0)