Skip to content

Handle case clause corner cases in extract symbol#21370

Merged
amcasey merged 2 commits into
microsoft:masterfrom
amcasey:GH20559
Jan 23, 2018
Merged

Handle case clause corner cases in extract symbol#21370
amcasey merged 2 commits into
microsoft:masterfrom
amcasey:GH20559

Conversation

@amcasey
Copy link
Copy Markdown
Member

@amcasey amcasey commented Jan 23, 2018

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 a CaseClause is not.

Fixes #20559

@amcasey amcasey requested a review from RyanCavanaugh January 23, 2018 19:12
@amcasey amcasey merged commit 0c763ed into microsoft:master Jan 23, 2018
@amcasey amcasey deleted the GH20559 branch January 23, 2018 21:33
@amcasey
Copy link
Copy Markdown
Member Author

amcasey commented Jan 23, 2018

@mhegazy Should this go in 2.7?

// 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);
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.

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.

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.

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.

@microsoft microsoft locked and limited conversation to collaborators Jul 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants