marijnh/tern — pull request #202 by sqs (2013-07-20 00:26:36+00:00)
Title: Refuse to define __proto__ maybeProps

This PR is primarily a failing test case for some unexpected behavior when setting docstrings on objects with a `__proto__`.

I believe there are other ways to trigger the error than the included `test/cases/proto_doc.js`, but I couldn't isolate any. Also, I had to add a dummy `forAllProps:` comment test directive to trigger the error (I knew it occurred when calling forAllProps but didn't know how to invoke it through the tern server in such a way to exhibit the error).

Without the patch to lib/infer.js, running the tests gives:

```
$ bin/test proto_doc
Ran 2 tests from 1 files.
All passed.

/home/sqs/src/tern/lib/infer.js:651
list[i + 1].addType(list[i], list[i + 2]);
^
TypeError: Object function toString() { [native code] } has no method 'addType'
at withWorklist (/home/sqs/src/tern/lib/infer.js:651:21)
at Object.extend.propagate (/home/sqs/src/tern/lib/infer.js:88:25)
at Object.extend.forAllProps (/home/sqs/src/tern/lib/infer.js:104:12)
at query.type (/home/sqs/src/tern/test/runcases.js:127:20)
at Object.exports.withContext (/home/sqs/src/tern/lib/infer.js:630:18)
at /home/sqs/src/tern/test/runcases.js:123:17
at /home/sqs/src/tern/test/runcases.js:172:7
at Array.forEach (native)
at Object.exports.runTests (/home/sqs/src/tern/test/runcases.js:59:27)
at Object. (/home/sqs/src/tern/bin/test:5:29)
```

With the patch, which I am not sure is correct, the tests pass.