-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Revert: Revert "Set val escape on expression variables (#64414)" #64633
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
Conversation
This reverts commit 2ca2359.
| var variableSymbol = variableOpt switch | ||
| { | ||
| DeconstructionVariablePendingInference { VariableSymbol: var symbol } => symbol, | ||
| BoundLocal { DeclarationKind: BoundLocalDeclarationKind.WithExplicitType or BoundLocalDeclarationKind.WithInferredType, LocalSymbol: var symbol } => symbol, |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
|
The second commit needs a second review. |
Revert: Revert "Set val escape on expression variables (dotnet#64414)" Co-authored-by: Rikki Gibson <rigibson@microsoft.com>
Commit 1: Revert: Revert "Set val escape on expression variables (#64414)"
Commit 2: Update escape analysis to ignore local declarations only.