carlitux / deoplete-ternjs

deoplete.nvim source for javascript
MIT License
277 stars 24 forks source link

Tern errors out with object spread #74

Closed FuzzOli87 closed 6 years ago

FuzzOli87 commented 6 years ago

I've been having issues with tern staying up after updating my plugins. This is the error received:

image

I'll do some more debugging if I have time!

carlitux commented 6 years ago

@FuzzOli87 looks like this is ternjs plugins bug.

FuzzOli87 commented 6 years ago

@carlitux I did a bit of digging and found that object spread causes tern to break and I'm not sure if the fault lies in the request that is sent or tern itself:

const obj = {
  hi: 'hello'
};

const newObj = {
  hello: 'hi',
  ...obj
}

The above will fail as soon as I type the second (.) in the spread. The request sent is:

Request: {
  "query": {
    "type": "completions",
    "types": false,
    "depths": false,
    "docs": false,
    "filter": true,
    "caseInsensitive": false,
    "guess": true,
    "sort": false,
    "expandWordForward": true,
    "omitObjectPrototype": false,
    "includeKeywords": false,
    "inLiteral": true,
    "file": "#0",
    "end": {
      "line": 6,
      "ch": 4
    },
    "lineCharPositions": true
  },
  "files": [
    {
      "type": "full",
      "name": "src/logger.js",
      "text": "const obj = {\n  hi: 'hello'\n};\n\nconst newObj = {\n  hello: 'hi',\n  ..\n}"
    }
  ]
}
/usr/local/lib/node_modules/tern/lib/infer.js:1403
        if (prop.key.name == "__proto__") {
                     ^

TypeError: Cannot read property 'name' of undefined

Tern recently updated so they might of changed something. This worked fine before!

FuzzOli87 commented 6 years ago

@carlitux I just installed tern 0.21.0 and it works again. So I'll open up an issue on there. It wasn't a major release version so I didn't think it would break anything.

carlitux commented 6 years ago

cool, thanks for update

FuzzOli87 commented 6 years ago

This was not an issue with this library but with tern and has been fixed by 0.22.2.