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

Do not expose operation nodes for BoundRangeVariables in C# query exp… #23080

Merged
merged 5 commits into from
Nov 15, 2017

Conversation

mavasani
Copy link
Contributor

@mavasani mavasani commented Nov 8, 2017

…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

…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 };
Copy link
Contributor Author

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.

@tmat
Copy link
Member

tmat commented Nov 9, 2017

test ubuntu_16_debug_prtest please

@mavasani
Copy link
Contributor Author

mavasani commented Nov 9, 2017

test ubuntu_16_debug_prtest please

@natidea
Copy link
Contributor

natidea commented Nov 9, 2017

@@ -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;
Copy link
Contributor

@AlekseyTs AlekseyTs Nov 10, 2017

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')
Copy link
Contributor

@AlekseyTs AlekseyTs Nov 10, 2017

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')
Copy link
Contributor

@AlekseyTs AlekseyTs Nov 10, 2017

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')
Copy link
Contributor

@AlekseyTs AlekseyTs Nov 10, 2017

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

Copy link
Contributor Author

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"/>
Copy link
Contributor

@AlekseyTs AlekseyTs Nov 10, 2017

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 };
Copy link
Contributor

@AlekseyTs AlekseyTs Nov 10, 2017

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

@AlekseyTs
Copy link
Contributor

AlekseyTs commented Nov 10, 2017

                return new BoundRangeVariable(node, qv, translation, translation.Type);

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)

@AlekseyTs
Copy link
Contributor

AlekseyTs commented Nov 10, 2017

Done with review pass (iteration 3). #Closed

@mavasani
Copy link
Contributor Author

@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)
Copy link
Contributor

@AlekseyTs AlekseyTs Nov 13, 2017

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')
Copy link
Contributor

@AlekseyTs AlekseyTs Nov 13, 2017

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

Copy link
Contributor Author

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.

@AlekseyTs
Copy link
Contributor

AlekseyTs commented Nov 13, 2017

Done with review pass (iteration 4). #Closed

@mavasani
Copy link
Contributor Author

@AlekseyTs addressed your feedback.

@cston @jcouv @dotnet/analyzer-ioperation Can I get a review?

Copy link
Contributor

@AlekseyTs AlekseyTs left a comment

Choose a reason for hiding this comment

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

LGTM

@mavasani mavasani changed the base branch from master to post-dev15.5-contrib November 14, 2017 19:53
@mavasani
Copy link
Contributor Author

Ping @dotnet/roslyn-compiler for one more review.

@mavasani mavasani merged commit 52a759e into dotnet:post-dev15.5-contrib Nov 15, 2017
@jcouv jcouv added this to the 15.6 milestone Jan 9, 2018
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.

7 participants