Fix crash in GetDeconstructionInfo#27605
Merged
jcouv merged 1 commit intodotnet:masterfrom Jun 8, 2018
Merged
Conversation
cston
approved these changes
Jun 8, 2018
AlekseyTs
reviewed
Jun 8, 2018
| { | ||
| static void M(string s) | ||
| { | ||
| foreach (char in s) { } |
Contributor
There was a problem hiding this comment.
foreach (char in s) { } [](start = 8, length = 23)
I am curious why we are parsing this as ForEachVariableStatement
Member
Author
There was a problem hiding this comment.
Looking at the code (without stepping through it to confirm), here's what I think happens:
- we reach the open paren
- try to parse a declaration expression (
ParseExpressionOrDeclaration) - but
IsPossibleDeclarationExpressionscans ahead of the type to check for a designation (missing, keywordinis found) - having not found a declaration expression, we go down the route of interpreting the
foreachas not-a-simple-foreach, but rather a deconstruction foreach.
Member
Author
|
Marking as approved to merge for 15.8 preview 4. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Customer scenario
Type an incomplete
foreach (char in s) { }and hover your mouse over thein. The IDE will pop-up an exception dialog or crash.Bugs this fixes
Fixes #27520
Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/628435
Risk
Performance impact
Low. This fix is just adding a null check.
Is this a regression from a previous update?
Yes, this is a regression from 15.7.
Root cause analysis
Although the API (including this underlying bug) was introduced in 15.6, it was only used for Find All References. But in 15.8, I made a change to use this API in QuickInfo, which is much more common, especially on incomplete code.
How was the bug found?
Watson and bug report from a team member