Test plan for ExpressionVariables #25073
Labels
Area-Compilers
Resolution-Fixed
The bug has been fixed and/or the requested behavior has been implemented
Test
Test failures in roslyn-CI
Milestone
This is a test plan for the work in https://github.com/dotnet/roslyn/tree/features/ExpressionVariables
The championed proposal is at dotnet/csharplang#32
The proposal is at https://github.com/dotnet/csharplang/blob/master/proposals/expression-variables-in-initializers.md
Tests for many of the following probably predate this feature's implementation:
Test that an expression variable declaration in any of the three contexts is an error if the name is used to declare a local in an enclosing scope (does not apply to field initializers, which do not have an enclosing local scope) [See
Scope_Query_05
et al]\public C(int x1) : base(out int x1) { }
Test that an expression variable declaration in any of the three contexts is an error if the name is used to declare a local in a nested scope (does not apply to field initializers, which do not have a nested local scope)
public C() : base(out int x1) { int x1 = 0; }
from x1 in e where M1(M2(out var x2), from x3 in x2 where M(x1, out var x2) select x3) select x1
Test that an expression variable declaration in any of the three contexts is an error if the name is used to declare a local in the same scope [See
,
, and `` et al]public C() : base(M1(out int x1), M1(out int x1)) {}
static int F = M(M1(out int x1), M1(out int x1));
... where M(M1(out int x1), M1(out int x1)) ...
Each of the above for each of the ways a local can be declared (if possible)
Each of the above for each of the ways an expression variable can be declared (if possible)
Test that an expression variable declared in a ctor-initializer (test both this() and base())
ConstructorInitializers_06
]Scope_ConstructorInitializers_01
]Scope_ConstructorInitializers_03
]public C() : this(TakeOutParam(1, out var x1), x1)
public C() : this(TakeOutParam(1, out var x1, x1))
Test that an expression variable in a field initializer
Scope_FieldInitializers_01
]Scope_FieldInitializers_01
]Scope_FieldInitializers_01
]public field = M(out var x1, x1)
Test that an expression variable in a query clause
Scope_Query_01
]Scope_Query_01
]Scope_Query_01
]Scope_Query_01
]Scope_Query_01
]Each of the above for each of the ways an expression variable can be declared (if possible) [See corresponding tests in
PatternMatchingTests.cs
]Test that a variable declared in a field initializer is not in scope in a constructor. Need test (coming in Scope_FieldInitializers_04)
Test that an expression variable declared in the initializing expression of a top-level variable in a script is in the global scope of the script. Not sure (GlobalCode_FieldDeclaration_03 and the like)
For each kind of expression variable in each of the new contexts.
Demonstrate that the debug format produced by the compiler has support for it
Demonstrate that GetDeclaredSymbol yields the local symbol from the declaration
Demonstrate that GetSymbolInfo yields the local symbol from its use site
Demonstrate that GetSpeculativeSymbolInfo yields the local symbol from a speculative use site produced within its scope
Demonstrate that definite assignment analysis appropriately reports use of the variable where it is in scope but not definitely assigned Not sure (see tests added in OutVarTests.cs in Align PDB scope for variable declared within field initializers with sequence point. #25441) for these contexts
For flow analysis, add a test that demonstrates that there is an edge from the ctor-initializer to the body. (e.g. when definitely assigned, and when not definitely assigned). [See
Scope_ConstructorInitializers_03
for definitely-assigned; need a test (see ConstructorInitializers_10) for not-definitely-assigned]"Edit-and-continue logic needs to be updated to handle these variables, the new scopes, and closures capturing such variables. Changes and corresponding tests will be needed in both the compiler and the IDE" Pending (see Test EnC on expression variables in initializers and queries #25438)
Demonstrate that expression variables in these context appear correctly in IOperation. [See
Scope_FieldInitializers_02
,ConstructorBodyOperation
, and Need test (coming in Query_03) for query]Demonstrate that these new scopes for expression variables are only permitted when the language version is 7.3 or higher. [See
FieldInitializers_01
et al]Demonstrate that a variable in a ctor-initializer is "visible" to the debugger inside the ctor-initializer. Pending (see EE test LocalsInConstructorInitializer_01)
Demonstrate that a variable in a ctor-initializer is "visible" to the debugger inside the constructor body. Pending (see EE tests LocalsInConstructorInitializer_02, LocalsInConstructorInitializer_03)
PR with additional tests #25519
/cc @AlekseyTs
The text was updated successfully, but these errors were encountered: