Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 9, 2014

Conversation

JsonFreeman
Copy link
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.

@@ -2144,9 +2144,16 @@ module ts {
}

// TODO: this is a hack for now, we need a proper walking mechanism to verify that we have the correct node
Copy link
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
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
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.

// declare function f(a: { xa: number; xb: number; });
// f({ |
if (!fullTypeCheck) {
if (candidates.length) {
Copy link
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
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
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