Handle case clause corner cases in extract symbol#21370
Merged
Conversation
(mostly by rejecting them) Fixes microsoft#20559
RyanCavanaugh
approved these changes
Jan 23, 2018
Member
Author
|
@mhegazy Should this go in 2.7? |
amcasey
commented
Jan 24, 2018
| // they will never find `start` in `start.parent.statements`. | ||
| // Consider: We could support ranges like [|case 1:|] by refining them to just | ||
| // the expression. | ||
| Debug.assert(isCaseClause(start.parent) && span.start < start.parent.expression.end); |
Member
Author
There was a problem hiding this comment.
This assert is incorrect. There are other ways this can arise. I'm still trying to determine if a sensible assert is possible. If not, deleting it should suffice - the only downside of returning early is not being able to extract a range.
Member
Author
There was a problem hiding this comment.
It looks like it can happen with any non-statement child of a block-like node (e.g. the lbrace in a block). I'll just remove the assert.
This was referenced Jan 24, 2018
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
There's a utility method,
isBlockLike, used to determine whether a node has a list of statements. Unfortunately, the callers of that method assumed that all children were in the list of statements. The expression of aCaseClauseis not.Fixes #20559