ternjs / tern

A JavaScript code analyzer for deep, cross-editor language support
https://ternjs.net/
MIT License
4.25k stars 378 forks source link

tern crashes on attempt to bind a class #1013

Closed surr-name closed 5 years ago

surr-name commented 5 years ago

This code breaks tern server:

class Some {}

Some.bind(nu

output of the server:

Request: {
  "query": {
    "type": "completions",
    "types": true,
    "depths": true,
    "docs": true,
    "filter": false,
    "caseInsensitive": true,
    "guess": true,
    "sort": false,
    "expandWordForward": true,
    "omitObjectPrototype": false,
    "includeKeywords": true,
    "inLiteral": true,
    "file": "#0",
    "end": {
      "line": 2,
      "ch": 10
    },
    "lineCharPositions": true
  },
  "files": [
    {
      "type": "full",
      "name": "index.js",
      "text": "class Some {}\n\nSome.bind(nu"
    }
  ]
}
/usr/local/lib/node_modules/tern/lib/def.js:634
                                       tp.argNames.slice(this.args.length), tp.retval, tp.generator));
                                                   ^

TypeError: Cannot read property 'slice' of null
    at ctor.addType (/usr/local/lib/node_modules/tern/lib/def.js:634:52)
    at exports.Fn.propagate (/usr/local/lib/node_modules/tern/lib/infer.js:529:35)
    at /usr/local/lib/node_modules/tern/lib/def.js:644:10
    at ctor.addType (/usr/local/lib/node_modules/tern/lib/infer.js:382:18)
    at withWorklist (/usr/local/lib/node_modules/tern/lib/infer.js:922:19)
    at exports.AVal.propagate (/usr/local/lib/node_modules/tern/lib/infer.js:94:25)
    at /usr/local/lib/node_modules/tern/lib/infer.js:1563:14
    at /usr/local/lib/node_modules/tern/lib/infer.js:1391:7
    at infer (/usr/local/lib/node_modules/tern/lib/infer.js:1652:22)
    at Object.Expression (/usr/local/lib/node_modules/tern/lib/infer.js:1661:7)
othree commented 5 years ago

Thank you, will release this fix soon.