Skip to content

Conversation

@cston
Copy link
Contributor

@cston cston commented Oct 11, 2022

Commit 1: Revert: Revert "Set val escape on expression variables (#64414)"
Commit 2: Update escape analysis to ignore local declarations only.

@cston cston marked this pull request as ready for review October 11, 2022 18:46
@cston cston requested a review from a team as a code owner October 11, 2022 18:46
var variableSymbol = variableOpt switch
{
DeconstructionVariablePendingInference { VariableSymbol: var symbol } => symbol,
BoundLocal { DeclarationKind: BoundLocalDeclarationKind.WithExplicitType or BoundLocalDeclarationKind.WithInferredType, LocalSymbol: var symbol } => symbol,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have other cases where we check DeclarationKind: not BoundLocalDeclarationKind.None. In future we might want to be consistent here, or maybe introduce an extension/computed property which asks if the bound-local represents a user-visible variable declaration, which throws when an unknown DeclarationKind is encountered.

No need to change anything in this PR.

// (34,9): error CS8350: This combination of arguments to 'R1.Deconstruct(out int, out R2)' is disallowed because it may expose variables referenced by parameter 'this' outside of their declaration scope
// r.Deconstruct(out var x4, out var y4);
Diagnostic(ErrorCode.ERR_CallArgMixing, "r.Deconstruct(out var x4, out var y4)").WithArguments("R1.Deconstruct(out int, out R2)", "this").WithLocation(34, 9));
// (16,16): error CS8352: Cannot use variable 'y1' in this context because it may expose referenced variables outside of their declaration scope
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: consider indenting this to match the previous test baseline

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll update the indenting in a follow-up PR, unless other changes are needed in this PR.

@RikkiGibson RikkiGibson requested a review from a team October 11, 2022 19:40
@RikkiGibson
Copy link
Member

The second commit needs a second review.

@cston cston merged commit 00db7b1 into dotnet:main Oct 11, 2022
@ghost ghost added this to the Next milestone Oct 11, 2022
@cston cston deleted the revert-64627 branch October 11, 2022 20:21
RikkiGibson added a commit to RikkiGibson/roslyn that referenced this pull request Oct 11, 2022
Revert: Revert "Set val escape on expression variables (dotnet#64414)"

Co-authored-by: Rikki Gibson <rigibson@microsoft.com>
@RikkiGibson RikkiGibson modified the milestones: Next, 17.5 P1 Oct 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants