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

Out arguments do not contribute val escape #64784

Merged
merged 4 commits into from
Nov 28, 2022

Conversation

RikkiGibson
Copy link
Contributor

@RikkiGibson RikkiGibson commented Oct 17, 2022

Closes #64783
Closes #56587

Although out arguments never contribute their val escape, arguments for [UnscopedRef] out parameters can contribute their ref escape. See test LocalScope_DeclarationExpression_07.

@RikkiGibson RikkiGibson requested a review from a team as a code owner October 17, 2022 22:59
@RikkiGibson RikkiGibson marked this pull request as draft October 18, 2022 00:26
@@ -2427,9 +2432,9 @@ void inferDeclarationExpressionValEscape()
: GetValEscape(fromArg, scopeOfTheContainingExpression));
}

foreach (var (_, fromArg, _, _) in escapeValues)
foreach (var argument in argsOpt)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since out arguments are usually not included in escapeValues, we needed to change to check argsOpt instead. Note that escapeValues was probably never the right collection to enumerate, since the same argument can be present multiple times, it just happened to work coincidentally until now.

Copy link
Contributor Author

@RikkiGibson RikkiGibson Nov 22, 2022

Choose a reason for hiding this comment

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

Also, although it doesn't look like argsOpt is default-checked on this code path, I actually think that the argument passed for argsOpt is never default. I'll send a separate PR after this one to add an assertion and rename the parameter.

@RikkiGibson RikkiGibson marked this pull request as ready for review November 23, 2022 04:27
@RikkiGibson
Copy link
Contributor Author

@dotnet/roslyn-compiler for review

@RikkiGibson RikkiGibson requested a review from a team November 28, 2022 20:49
@RikkiGibson RikkiGibson merged commit 91d6e86 into dotnet:main Nov 28, 2022
@ghost ghost added this to the Next milestone Nov 28, 2022
@RikkiGibson RikkiGibson deleted the out-val-escape branch November 28, 2022 21:12
@allisonchou allisonchou modified the milestones: Next, 17.5 P2 Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants