{"action":"created","issue":{"url":"https://api.github.com/repos/marijnh/tern/issues/531","labels_url":"https://api.github.com/repos/marijnh/tern/issues/531/labels{/name}","comments_url":"https://api.github.com/repos/marijnh/tern/issues/531/comments","events_url":"https://api.github.com/repos/marijnh/tern/issues/531/events","html_url":"https://github.com/marijnh/tern/issues/531","id":70655009,"number":531,"title":"TypeError: Cannot read property 'reuseInstances' of undefined","user":{"login":"gfwilliams","id":754445,"avatar_url":"https://avatars.githubusercontent.com/u/754445?v=3","gravatar_id":"","url":"https://api.github.com/users/gfwilliams","html_url":"https://github.com/gfwilliams","followers_url":"https://api.github.com/users/gfwilliams/followers","following_url":"https://api.github.com/users/gfwilliams/following{/other_user}","gists_url":"https://api.github.com/users/gfwilliams/gists{/gist_id}","starred_url":"https://api.github.com/users/gfwilliams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gfwilliams/subscriptions","organizations_url":"https://api.github.com/users/gfwilliams/orgs","repos_url":"https://api.github.com/users/gfwilliams/repos","events_url":"https://api.github.com/users/gfwilliams/events{/privacy}","received_events_url":"https://api.github.com/users/gfwilliams/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-24T10:42:41Z","updated_at":"2015-04-29T13:23:59Z","closed_at":"2015-04-29T13:23:59Z","body":"Hi,\r\n\r\nI just updated to the latest acorn and tern from NPM, and I now get the following error\r\n\r\n```\r\n/usr/lib/node_modules/tern/lib/infer.js:388\r\n      if (cx.parent && !cx.parent.options.reuseInstances) this.noReuse = true;\r\n                                         ^\r\nTypeError: Cannot read property 'reuseInstances' of undefined\r\n    at Object.exports.IsCtor.constraint.addType (/usr/lib/node_modules/tern/lib/infer.js:388:42)\r\n    at withWorklist (/usr/lib/node_modules/tern/lib/infer.js:772:21)\r\n    at Object.extend.propagate (/usr/lib/node_modules/tern/lib/infer.js:90:25)\r\n    at inferExprVisitor.NewExpression (/usr/lib/node_modules/tern/lib/infer.js:1126:14)\r\n    at Object.NewExpression (/usr/lib/node_modules/tern/lib/infer.js:990:7)\r\n    at infer (/usr/lib/node_modules/tern/lib/infer.js:1176:39)\r\n    at Object.walk.make.VariableDeclaration (/usr/lib/node_modules/tern/lib/infer.js:1196:11)\r\n    at c (/usr/lib/node_modules/acorn/dist/walk.js:82:35)\r\n    at Object.skipThrough [as Statement] (/usr/lib/node_modules/acorn/dist/walk.js:180:3)\r\n    at c (/usr/lib/node_modules/acorn/dist/walk.js:82:35)\r\n```\r\n\r\nIt would appear to be triggered by the following code:\r\n\r\n```\r\nvar infer = require(\"tern/lib/infer\");\r\n\r\nvar defs = [{\r\n  \"OneWire\": {\r\n    \"!type\": \"fn(pin: +Pin) -> ?\",\r\n    \"!doc\": \"Create a software OneWire implementation on the given pin\",\r\n    \"!url\": \"http://www.espruino.com/Reference#l_OneWire_OneWire\"\r\n  }\r\n}];\r\nvar fileContents = 'var ow = new OneWire(A1);\\n'+\r\n'var sensor = require(\"DS18B20\").connect(ow);\\n'+\r\n'setInterval(function() {\\n'+\r\n'  console.log(sensor.getTemp());\\n'+\r\n'}, 1000);';\r\n\r\nvar cx = new infer.Context(defs, this);\r\ninfer.withContext(cx, function() {\r\n    var ast = infer.parse(fileContents);\r\n    infer.analyze(ast, \"myID\");\r\n});\r\n```\r\n\r\nI've stripped this back a bit, but running it triggers the problem. Removing `defs` makes it work.\r\n\r\nThis *used to work* before I updated tern/acorn - any ideas what I'm doing wrong? Has the format of  'defs' changed?\r\n\r\nthanks!\r\n"},"comment":{"url":"https://api.github.com/repos/marijnh/tern/issues/comments/97423791","html_url":"https://github.com/marijnh/tern/issues/531#issuecomment-97423791","issue_url":"https://api.github.com/repos/marijnh/tern/issues/531","id":97423791,"user":{"login":"marijnh","id":144427,"avatar_url":"https://avatars.githubusercontent.com/u/144427?v=3","gravatar_id":"","url":"https://api.github.com/users/marijnh","html_url":"https://github.com/marijnh","followers_url":"https://api.github.com/users/marijnh/followers","following_url":"https://api.github.com/users/marijnh/following{/other_user}","gists_url":"https://api.github.com/users/marijnh/gists{/gist_id}","starred_url":"https://api.github.com/users/marijnh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marijnh/subscriptions","organizations_url":"https://api.github.com/users/marijnh/orgs","repos_url":"https://api.github.com/users/marijnh/repos","events_url":"https://api.github.com/users/marijnh/events{/privacy}","received_events_url":"https://api.github.com/users/marijnh/received_events","type":"User","site_admin":false},"created_at":"2015-04-29T13:23:59Z","updated_at":"2015-04-29T13:23:59Z","body":"Why are you passing the global scope object as `parent` argument to `new infer.Context`? That should either be null or a `tern.Server` instance. Remove that argument, and you should get better results."}}