-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Conversation
217d55e
to
48c6a89
Compare
@@ -2427,9 +2432,9 @@ void inferDeclarationExpressionValEscape() | |||
: GetValEscape(fromArg, scopeOfTheContainingExpression)); | |||
} | |||
|
|||
foreach (var (_, fromArg, _, _) in escapeValues) | |||
foreach (var argument in argsOpt) |
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.
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.
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.
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.
@dotnet/roslyn-compiler for review |
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.