ternjs / tern_for_sublime

Sublime Text package adding Tern support
MIT License
803 stars 54 forks source link

Mysterious error " #36

Closed dillonkrug closed 10 years ago

dillonkrug commented 10 years ago

I was working on a file when this alert kept popping up: Mysterious Alert

I tracked it down to tern_for_sublime, and this particular bit of code:

return {
    //
    a: ''
}

Note: That is an invalid return statement, outside of a function.

If you copy that into a sublime js window, any time an autocomplete menu would pop up, you get that alert instead.

If you remove the return, the comment inside the object, or the object's property, it works normally. Also if the property is defined before the comment, there is no issue.

I checked to see if acorn throws an error with the same code but it seemed to parse it without a problem.

dillonkrug commented 10 years ago

I should probably also note that the alert happens any time something with that object/comment combination is "inside" the return statement:

return fn({
    //
    a: ' '
})
return {
    a:{
        b: {
            //
            c: ' '
        }
    }
}
marijnh commented 10 years ago

That was a side effect of the fact that the analyzer bailed out when seeing a return outside of a function, and thus didn't create analysis info for the return's inner nodes. Should be fixed by https://github.com/marijnh/tern/commit/ccc01287c89b0c4ca37e175cd420d81a435ebc3e