Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test plan for ExpressionVariables #25073

Closed
41 of 44 tasks
gafter opened this issue Feb 27, 2018 · 2 comments
Closed
41 of 44 tasks

Test plan for ExpressionVariables #25073

gafter opened this issue Feb 27, 2018 · 2 comments
Assignees
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

Comments

@gafter
Copy link
Member

gafter commented Feb 27, 2018

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]\

    • Need test (coming in Scope_ConstructorInitializers_07, ScopeOfPatternVariables_ConstructorInitializers_07) for parameter name then used for an expression variable in the ctor-initializer, e.g. 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)

    • Need test (coming in Scope_ConstructorInitializers_07, ScopeOfPatternVariables_ConstructorInitializers_07), e.g. public C() : base(out int x1) { int x1 = 0; }
    • Need test (coming in Scope_Query_11, ScopeOfPatternVariables_Query_11), e.g. 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]

    • Scope_ConstructorInitializers_01, Scope_ConstructorInitializers_02, ScopeOfPatternVariables_ConstructorInitializers_01, ScopeOfPatternVariables_ConstructorInitializers_02, e.g. public C() : base(M1(out int x1), M1(out int x1)) {}
    • Scope_FieldInitializers_01, ScopeOfPatternVariables_FieldInitializers_01, e.g. static int F = M(M1(out int x1), M1(out int x1));
    • Need test (comung in Scope_Query_11, ScopeOfPatternVariables_Query_11), e.g. ... 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())

    • can be used later in the ctor-initializer [See ConstructorInitializers_06]
    • cannot be used earlier in the ctor-initializer [See Scope_ConstructorInitializers_01]
    • can be used in the body (expression body, block body, or both) [See Scope_ConstructorInitializers_03]
    • can be inferred ConstructorInitializers_01, ConstructorInitializers_02, ConstructorInitializers_03, ConstructorInitializers_04 e.g. public C() : this(TakeOutParam(1, out var x1), x1)
      • But if an inferred out variable, may not be used later in the same argument list Need test (coming in Scope_ConstructorInitializers_07) e.g. public C() : this(TakeOutParam(1, out var x1, x1))
  • Test that an expression variable in a field initializer

    • may be used later in that same initializing expression [See Scope_FieldInitializers_01]
    • may not be used before its point of declaration [See Scope_FieldInitializers_01]
    • is not in scope in the initializers for any other fields (even in the same declaration). [See Scope_FieldInitializers_01]
    • can be inferred [coming in FieldInitializers_06]
      • But if an inferred out variable, may not be used later in the same argument list Need test (coming in Scope_FieldInitializers_04), e.g. public field = M(out var x1, x1)
  • Test that an expression variable in a query clause

    • may be used later in that same expression of the query clause [See Scope_Query_01]
    • may not be used before its point of declaration [See Scope_Query_01]
    • is not in scope in other expressions of the query clause [See Scope_Query_01]
    • is not in scope in other query clauses [See Scope_Query_01]
    • can be inferred [See Scope_Query_01]
      • But if an inferred out variable, may not be used later in the same argument list [coming in Scope_Query_11]
  • 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

@gafter gafter added Area-Compilers Test Test failures in roslyn-CI labels Feb 27, 2018
@gafter gafter added this to the 15.7 milestone Feb 27, 2018
@gafter gafter self-assigned this Feb 27, 2018
@gafter gafter added this to Next Up in Compiler: Gafter Feb 27, 2018
@tmat
Copy link
Member

tmat commented Feb 27, 2018

EnC 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.
@ivanbasov @jinujoseph

@gafter gafter changed the title [Draft] Test plan for ExpressionVariables Test plan for ExpressionVariables Mar 6, 2018
@gafter gafter added the Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented label Mar 26, 2018
@gafter gafter closed this as completed Mar 26, 2018
@gafter gafter reopened this Mar 26, 2018
@gafter
Copy link
Member Author

gafter commented Mar 26, 2018

#25438 contains tests for EnC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented Test Test failures in roslyn-CI
Projects
None yet
Development

No branches or pull requests

2 participants