Skip to content

Parens on tuple literals can be simplified#25986

Merged
jcouv merged 1 commit intodotnet:masterfrom
jcouv:tuple-inline
Apr 7, 2018
Merged

Parens on tuple literals can be simplified#25986
jcouv merged 1 commit intodotnet:masterfrom
jcouv:tuple-inline

Conversation

@jcouv
Copy link
Copy Markdown
Member

@jcouv jcouv commented Apr 6, 2018

When inlining a local that is defined with a tuple literal, the inlined expression doesn't need to be parenthesized.

Addresses part of #11028

@jcouv jcouv added the Area-IDE label Apr 6, 2018
@jcouv jcouv added this to the 15.8 milestone Apr 6, 2018
@jcouv jcouv self-assigned this Apr 6, 2018
@jcouv jcouv requested a review from a team as a code owner April 6, 2018 05:28
@jcouv
Copy link
Copy Markdown
Member Author

jcouv commented Apr 6, 2018

@dotnet/roslyn-ide for review. Tiny tiny change. Thanks

}

// ((x, y)) -> (x, y)
if (expression.IsKind(SyntaxKind.TupleExpression))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is this true always? there's no worry that this might introduce an ambiguity in some cases? in other words, do we need to check the parent at all?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think so. I couldn't come up with any scenario where it is useful to have parens around a tuple.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks! LGTM then.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So long as it is not a cast, this is legal, right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@DustinCampbell Right. Here we're dealing with a parenthesized expression, not a cast syntax.

@jcouv
Copy link
Copy Markdown
Member Author

jcouv commented Apr 6, 2018

test windows_release_unit32_prtest please

@jcouv
Copy link
Copy Markdown
Member Author

jcouv commented Apr 6, 2018

test windows_debug_unit64_prtest please

@jcouv jcouv merged commit 015440f into dotnet:master Apr 7, 2018
@jcouv jcouv deleted the tuple-inline branch April 7, 2018 01:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants