-
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
Do not expose operation nodes for BoundRangeVariables in C# query exp… #23080
Do not expose operation nodes for BoundRangeVariables in C# query exp… #23080
Conversation
…ression These nodes contain the bound parameter reference to the underlying lambda parameter, which is now exposed. Fixes dotnet#23079
@@ -43,14 +43,14 @@ protected override BoundExpression BindRangeVariable(SimpleNameSyntax node, Rang | |||
// the range variable maps directly to a use of the parameter of that name | |||
var value = base.parameterMap[qv.Name]; | |||
Debug.Assert(value.Count == 1); | |||
translation = new BoundParameter(node, value.Single()) { WasCompilerGenerated = true }; |
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.
This is causing test failures where GetSymbolInfo is now returning parameter symbol instead of range variable symbol. I will revert the changes to this file and attempt to handle this correctly in the operation factory.
…meter is marked explicit
test ubuntu_16_debug_prtest please |
test ubuntu_16_debug_prtest please |
Approved to merge via https://devdiv.visualstudio.com/DevDiv/_workitems/edit/521947 |
@@ -456,7 +459,8 @@ private IParameterReferenceOperation CreateBoundParameterOperation(BoundParamete | |||
SyntaxNode syntax = boundParameter.Syntax; | |||
ITypeSymbol type = boundParameter.Type; | |||
Optional<object> constantValue = ConvertToOptional(boundParameter.ConstantValue); | |||
bool isImplicit = boundParameter.WasCompilerGenerated; | |||
// We want to mark compiler generated parameter reference for range variables as explicit because we don't expose any operation nodes for range variables. | |||
bool isImplicit = boundParameter.WasCompilerGenerated && boundParameter.AssociatedRangeVariable == null; |
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.
&& boundParameter.AssociatedRangeVariable == null [](start = 65, length = 50)
This doesn't feel right only top level node in the BoundRangeVariable.Value should be explicit and only if BoundRangeVariable itself wasnt compiler generated #Closed
@@ -996,11 +992,15 @@ public static void Main(string[] args) | |||
IArgumentOperation (ArgumentKind.Explicit, Matching Parameter: z) (OperationKind.Argument, Type: null, IsImplicit) (Syntax: 'g + x*100') | |||
IBinaryOperation (BinaryOperatorKind.Add) (OperationKind.BinaryOperator, Type: System.Int32) (Syntax: 'g + x*100') | |||
Left: | |||
IOperation: (OperationKind.None, Type: null) (Syntax: 'g') | |||
IPropertyReferenceOperation: System.Int32 <anonymous type: System.Int32 x, System.Int32 g>.g { get; } (OperationKind.PropertyReference, Type: System.Int32, IsImplicit) (Syntax: 'g') |
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.
IsImplicit [](start = 200, length = 10)
This node should be explicit, receiver should be implicit. #Closed
Instance Receiver: | ||
IPropertyReferenceOperation: <anonymous type: System.Int32 x, System.Int32 g> <anonymous type: <anonymous type: System.Int32 x, System.Int32 g> <>h__TransparentIdentifier0, System.Int32 z>.<>h__TransparentIdentifier0 { get; } (OperationKind.PropertyReference, Type: <anonymous type: System.Int32 x, System.Int32 g>, IsImplicit) (Syntax: 'x') | ||
Instance Receiver: | ||
IParameterReferenceOperation: <>h__TransparentIdentifier1 (OperationKind.ParameterReference, Type: <anonymous type: <anonymous type: System.Int32 x, System.Int32 g> <>h__TransparentIdentifier0, System.Int32 z>) (Syntax: 'x') |
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.
IParameterReferenceOperation [](start = 36, length = 28)
This node should be implicit. #Closed
IOperation: (OperationKind.None, Type: null) (Syntax: 'x') | ||
IOperation: (OperationKind.None, Type: null) (Syntax: 'x') | ||
IParameterReferenceOperation: x (OperationKind.ParameterReference, Type: System.Int32) (Syntax: 'x') | ||
IParameterReferenceOperation: x (OperationKind.ParameterReference, Type: System.Int32) (Syntax: 'x') |
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.
IParameterReferenceOperation: x (OperationKind.ParameterReference, Type: System.Int32) (Syntax: 'x') [](start = 6, length = 100)
It doesn't look like the initializers are in the right order. #Closed
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.
Tracked with #23115
@@ -1021,6 +1021,8 @@ | |||
<Field Name="Type" Type="TypeSymbol" Override="true" Null="disallow"/> | |||
|
|||
<Field Name="ParameterSymbol" Type="ParameterSymbol"/> | |||
<!-- If this is a compiler generated parameter reference created for a range variable access in query expression, then this contains the range variable --> | |||
<Field Name="AssociatedRangeVariable" Type="RangeVariableSymbol" Null="allow"/> |
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.
[](start = 4, length = 79)
I think we don't actually need this property because, often, the parameter itself is not associated with a range variable, but a property accessed of off the parameter is associated instead. #Closed
@@ -43,14 +43,14 @@ protected override BoundExpression BindRangeVariable(SimpleNameSyntax node, Rang | |||
// the range variable maps directly to a use of the parameter of that name | |||
var value = base.parameterMap[qv.Name]; | |||
Debug.Assert(value.Count == 1); | |||
translation = new BoundParameter(node, value.Single()) { WasCompilerGenerated = true }; | |||
translation = new BoundParameter(node, value.Single(), associatedRangeVariable: qv) { WasCompilerGenerated = true }; |
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.
{ WasCompilerGenerated = true } [](start = 108, length = 31)
I think you initial change too remove WasCompilerGenerated = true
was the right thing to do. We simply need to override VisitRangeVariable in Microsoft.CodeAnalysis.CSharp.MemberSemanticModel.NodeMapBuilder in such a way so that BoundRangeVariable.Value isn't visited. #Closed
We should make sure that the top node remains WasCompilerGenerated == false #Closed Refers to: src/Compilers/CSharp/Portable/Binder/Binder.WithQueryLambdaParametersBinder.cs:62 in 43e6ce0. [](commit_id = 43e6ce0, deletion_comment = False) |
Done with review pass (iteration 3). #Closed |
@AlekseyTs Addressed your feedback |
@@ -411,7 +411,7 @@ public BoundParameter(SyntaxNode syntax, ParameterSymbol parameterSymbol, bool h | |||
} | |||
|
|||
public BoundParameter(SyntaxNode syntax, ParameterSymbol parameterSymbol) | |||
: this(syntax, parameterSymbol, parameterSymbol.Type) | |||
: this(syntax, parameterSymbol, type: parameterSymbol.Type) |
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.
: this(syntax, parameterSymbol, type: parameterSymbol.Type) [](start = 12, length = 59)
Consider reverting changes to this file. #Closed
@@ -3597,7 +3639,9 @@ where x.ToString() == y.ToString() | |||
Children(1): | |||
IOperation: (OperationKind.None, Type: null, IsInvalid) (Syntax: 'x.ToString') | |||
Children(1): | |||
IOperation: (OperationKind.None, Type: null, IsInvalid) (Syntax: 'x') | |||
IInvalidOperation (OperationKind.Invalid, Type: ?, IsInvalid, IsImplicit) (Syntax: 'x') |
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.
IInvalidOperation (OperationKind.Invalid, Type: ?, IsInvalid, IsImplicit) (Syntax: 'x') [](start = 30, length = 87)
It feels like there should be an explicit node associated with (Syntax: 'x') and probably it should be this node. #Closed
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.
This seems to be due to incorrect implementation of IsImplicit for bad expression and statements in both C# and VB operation factories. Filed #23164 to track this issue.
Done with review pass (iteration 4). #Closed |
@AlekseyTs addressed your feedback. @cston @jcouv @dotnet/analyzer-ioperation Can I get a review? |
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.
LGTM
Ping @dotnet/roslyn-compiler for one more review. |
…ression
These nodes contain the bound parameter reference to the underlying lambda parameter, which is now exposed.
Fixes #23079
vso : https://devdiv.visualstudio.com/DevDiv/NET%20Developer%20Experience%20Productivity/_workitems/edit/521947