Skip to content

Fix crash when getting member completion for an object literal#853

Merged
mhegazy merged 4 commits into
masterfrom
objectLiteralCompletion
Oct 9, 2014
Merged

Fix crash when getting member completion for an object literal#853
mhegazy merged 4 commits into
masterfrom
objectLiteralCompletion

Conversation

@JsonFreeman
Copy link
Copy Markdown
Contributor

The following code caused a crash:

function f(a: { xa?: number; xb?: number; }) { }
var xc;
f({
    $

This changes the find the relevant token at the beginning of getCompletionsAtPosition. This fixes the crash, but the following case still does not work:

function f(a: { xa: number; xb: number; }) { }
var xc;
f({
    $

This represents the next item to be done, which is making the type checker give us the right contextual type.

Comment thread src/services/services.ts
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.

It's not really clear what is going on for someone running into the code for the first time. I didn't figure it out until I read the assertion. Please add a quick comment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Is there a particular question you want answered? Basically, we start with a Fidelity node, and we have to find the corresponding AST node. @mhegazy said he is working on removing the Fidelity part, so that might make it clearer.

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.

Right, I just mean a quick comment explaining that we are trying to find corresponding AST nodes for fidelity nodes.

Comment thread src/compiler/checker.ts Outdated
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.

candidates.length > 0

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.

actually I will just remove the check. it is a for loop after all. thanks.

@DanielRosenwasser
Copy link
Copy Markdown
Member

👍

mhegazy added a commit that referenced this pull request Oct 9, 2014
Fix crash when getting member completion for an object literal
@mhegazy mhegazy merged commit 2d2c4a9 into master Oct 9, 2014
@mhegazy mhegazy deleted the objectLiteralCompletion branch October 9, 2014 00:34
@microsoft microsoft locked and limited conversation to collaborators Jun 18, 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.

3 participants