{"action":"created","comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/comments/28814751","id":28814751,"diff_hunk":"@@ -152,51 +202,34 @@ module ts {\n                     // Report errors every position with duplicate declaration\r\n                     // Report errors on previous encountered declarations\r\n                     let message = symbol.flags & SymbolFlags.BlockScopedVariable\r\n-                        ? Diagnostics.Cannot_redeclare_block_scoped_variable_0 \r\n+                        ? Diagnostics.Cannot_redeclare_block_scoped_variable_0\r\n                         : Diagnostics.Duplicate_identifier_0;\r\n-\r\n                     forEach(symbol.declarations, declaration => {\r\n                         file.bindDiagnostics.push(createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration)));\r\n                     });\r\n                     file.bindDiagnostics.push(createDiagnosticForNode(node.name || node, message, getDisplayName(node)));\r\n \r\n-                    symbol = createSymbol(0, name);\r\n+                    symbol = createSymbol(SymbolFlags.None, name);\r\n                 }\r\n             }\r\n             else {\r\n-                symbol = createSymbol(0, \"__missing\");\r\n+                symbol = createSymbol(SymbolFlags.None, \"__missing\");\r\n             }\r\n+\r\n             addDeclarationToSymbol(symbol, node, includes);\r\n             symbol.parent = parent;\r\n \r\n-            if ((node.kind === SyntaxKind.ClassDeclaration || node.kind === SyntaxKind.ClassExpression) && symbol.exports) {\r\n-                // TypeScript 1.0 spec (April 2014): 8.4\r\n-                // Every class automatically contains a static property member named 'prototype', \r\n-                // the type of which is an instantiation of the class type with type Any supplied as a type argument for each type parameter.\r\n-                // It is an error to explicitly declare a static property member with the name 'prototype'.\r\n-                let prototypeSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Prototype, \"prototype\");\r\n-                if (hasProperty(symbol.exports, prototypeSymbol.name)) {\r\n-                    if (node.name) {\r\n-                        node.name.parent = node;\r\n-                    }\r\n-                    file.bindDiagnostics.push(createDiagnosticForNode(symbol.exports[prototypeSymbol.name].declarations[0],\r\n-                        Diagnostics.Duplicate_identifier_0, prototypeSymbol.name));\r\n-                }\r\n-                symbol.exports[prototypeSymbol.name] = prototypeSymbol;\r\n-                prototypeSymbol.parent = symbol;\r\n-            }\r\n-\r\n             return symbol;\r\n         }\r\n \r\n-        function declareModuleMember(node: Declaration, symbolKind: SymbolFlags, symbolExcludes: SymbolFlags) {\r\n+        function declareModuleMember(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): Symbol {\r\n             let hasExportModifier = getCombinedNodeFlags(node) & NodeFlags.Export;\r","path":"src/compiler/binder.ts","position":186,"original_position":186,"commit_id":"cf00a2bec859eaffa8d82698e57350a149bb2aa4","original_commit_id":"cf00a2bec859eaffa8d82698e57350a149bb2aa4","user":{"login":"vladima","id":8052307,"avatar_url":"https://avatars.githubusercontent.com/u/8052307?v=3","gravatar_id":"","url":"https://api.github.com/users/vladima","html_url":"https://github.com/vladima","followers_url":"https://api.github.com/users/vladima/followers","following_url":"https://api.github.com/users/vladima/following{/other_user}","gists_url":"https://api.github.com/users/vladima/gists{/gist_id}","starred_url":"https://api.github.com/users/vladima/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vladima/subscriptions","organizations_url":"https://api.github.com/users/vladima/orgs","repos_url":"https://api.github.com/users/vladima/repos","events_url":"https://api.github.com/users/vladima/events{/privacy}","received_events_url":"https://api.github.com/users/vladima/received_events","type":"User","site_admin":false},"body":"can be moved closer to use site","created_at":"2015-04-21T19:44:17Z","updated_at":"2015-04-21T19:44:17Z","html_url":"https://github.com/Microsoft/TypeScript/pull/2843#discussion_r28814751","pull_request_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/2843","_links":{"self":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/comments/28814751"},"html":{"href":"https://github.com/Microsoft/TypeScript/pull/2843#discussion_r28814751"},"pull_request":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/2843"}}},"pull_request":{"url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/2843","id":33732786,"html_url":"https://github.com/Microsoft/TypeScript/pull/2843","diff_url":"https://github.com/Microsoft/TypeScript/pull/2843.diff","patch_url":"https://github.com/Microsoft/TypeScript/pull/2843.patch","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/2843","number":2843,"state":"open","locked":false,"title":"Simplify binder flow. (alternate approach)","user":{"login":"CyrusNajmabadi","id":4564579,"avatar_url":"https://avatars.githubusercontent.com/u/4564579?v=3","gravatar_id":"","url":"https://api.github.com/users/CyrusNajmabadi","html_url":"https://github.com/CyrusNajmabadi","followers_url":"https://api.github.com/users/CyrusNajmabadi/followers","following_url":"https://api.github.com/users/CyrusNajmabadi/following{/other_user}","gists_url":"https://api.github.com/users/CyrusNajmabadi/gists{/gist_id}","starred_url":"https://api.github.com/users/CyrusNajmabadi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CyrusNajmabadi/subscriptions","organizations_url":"https://api.github.com/users/CyrusNajmabadi/orgs","repos_url":"https://api.github.com/users/CyrusNajmabadi/repos","events_url":"https://api.github.com/users/CyrusNajmabadi/events{/privacy}","received_events_url":"https://api.github.com/users/CyrusNajmabadi/received_events","type":"User","site_admin":false},"body":"This approach differs from PR https://github.com/Microsoft/TypeScript/pull/2832 in that it no longer uses SymbolFlags to control recursion and container setting logic in the binder.  Instead, we simply use the kind of the node we're currently on to determine what to do.  I personally think this is much cleaner and simpler, but i'm sending it out to see what other people think.  If you've already reviewed the previous PR, then you only have to start looking at this one with the commits starting on April 20th.\r\n\r\n--\r\n\r\nCR notes: I recommend reading this CR one commit at a time to better understand what's going on.\r\n\r\n--\r\n\r\nPreviously, it was very difficult to reason about the flow of the binder.  Different parts of the binder recursed in different ways.  For example, some codepaths called ```bindChildren```.  Others called ```forEachChild(node, bind)```.  Some codepaths did not recurse, but were called from paths that woudl then later ```break``` out and recurse.  This made it very easy to end up doing something wrong if you accidentally ```return```ed early.  It was also very difficult to know if you should should recurse if you were in ```bind``` or ```bindDeclaration``` or ```bindAnonymousDeclaration```.  The answer was always \"it depends\".\r\n\r\nI've gone in and completely unified the recursion logic in the binder.  The top level logic looks like this now:\r\n\r\n```ts\r\nbind(node: Node) {\r\n    // dispatch and bind this node only\r\n    // recurse and bind children\r\n}\r\n```\r\n\r\nThat's it.  Individual binding functions never need to worry about recursing.  Instead, they just deal with the node they have, and they top level bind driver will always be responsible for recursing.  This makes things much easier to reason about and provides a consistent framework for future binding code to follow.","created_at":"2015-04-21T06:38:33Z","updated_at":"2015-04-21T19:44:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f5bf91885ee0f54694ea3257b40a9ad69dd32795","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/2843/commits","review_comments_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/2843/comments","review_comment_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/2843/comments","statuses_url":"https://api.github.com/repos/Microsoft/TypeScript/statuses/cf00a2bec859eaffa8d82698e57350a149bb2aa4","head":{"label":"Microsoft:binderSimplification3","ref":"binderSimplification3","sha":"cf00a2bec859eaffa8d82698e57350a149bb2aa4","user":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":20929025,"name":"TypeScript","full_name":"Microsoft/TypeScript","owner":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Microsoft/TypeScript","description":"TypeScript is a superset of JavaScript that compiles to clean JavaScript output.","fork":false,"url":"https://api.github.com/repos/Microsoft/TypeScript","forks_url":"https://api.github.com/repos/Microsoft/TypeScript/forks","keys_url":"https://api.github.com/repos/Microsoft/TypeScript/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/TypeScript/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/TypeScript/teams","hooks_url":"https://api.github.com/repos/Microsoft/TypeScript/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/TypeScript/events","assignees_url":"https://api.github.com/repos/Microsoft/TypeScript/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/TypeScript/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/TypeScript/tags","blobs_url":"https://api.github.com/repos/Microsoft/TypeScript/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/TypeScript/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/TypeScript/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/TypeScript/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/TypeScript/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/TypeScript/languages","stargazers_url":"https://api.github.com/repos/Microsoft/TypeScript/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/TypeScript/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/TypeScript/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/TypeScript/subscription","commits_url":"https://api.github.com/repos/Microsoft/TypeScript/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/TypeScript/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/TypeScript/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/TypeScript/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/TypeScript/merges","archive_url":"https://api.github.com/repos/Microsoft/TypeScript/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/TypeScript/downloads","issues_url":"https://api.github.com/repos/Microsoft/TypeScript/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/TypeScript/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/TypeScript/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/TypeScript/releases{/id}","created_at":"2014-06-17T15:28:39Z","updated_at":"2015-04-21T17:34:14Z","pushed_at":"2015-04-21T19:08:53Z","git_url":"git://github.com/Microsoft/TypeScript.git","ssh_url":"git@github.com:Microsoft/TypeScript.git","clone_url":"https://github.com/Microsoft/TypeScript.git","svn_url":"https://github.com/Microsoft/TypeScript","homepage":"http://www.typescriptlang.org","size":743857,"stargazers_count":4721,"watchers_count":4721,"language":"TypeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":486,"mirror_url":null,"open_issues_count":570,"forks":486,"open_issues":570,"watchers":4721,"default_branch":"master"}},"base":{"label":"Microsoft:master","ref":"master","sha":"7f8e21b9b8656cd0345323f2ed05f97ac418584e","user":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":20929025,"name":"TypeScript","full_name":"Microsoft/TypeScript","owner":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Microsoft/TypeScript","description":"TypeScript is a superset of JavaScript that compiles to clean JavaScript output.","fork":false,"url":"https://api.github.com/repos/Microsoft/TypeScript","forks_url":"https://api.github.com/repos/Microsoft/TypeScript/forks","keys_url":"https://api.github.com/repos/Microsoft/TypeScript/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/TypeScript/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/TypeScript/teams","hooks_url":"https://api.github.com/repos/Microsoft/TypeScript/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/TypeScript/events","assignees_url":"https://api.github.com/repos/Microsoft/TypeScript/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/TypeScript/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/TypeScript/tags","blobs_url":"https://api.github.com/repos/Microsoft/TypeScript/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/TypeScript/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/TypeScript/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/TypeScript/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/TypeScript/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/TypeScript/languages","stargazers_url":"https://api.github.com/repos/Microsoft/TypeScript/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/TypeScript/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/TypeScript/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/TypeScript/subscription","commits_url":"https://api.github.com/repos/Microsoft/TypeScript/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/TypeScript/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/TypeScript/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/TypeScript/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/TypeScript/merges","archive_url":"https://api.github.com/repos/Microsoft/TypeScript/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/TypeScript/downloads","issues_url":"https://api.github.com/repos/Microsoft/TypeScript/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/TypeScript/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/TypeScript/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/TypeScript/releases{/id}","created_at":"2014-06-17T15:28:39Z","updated_at":"2015-04-21T17:34:14Z","pushed_at":"2015-04-21T19:08:53Z","git_url":"git://github.com/Microsoft/TypeScript.git","ssh_url":"git@github.com:Microsoft/TypeScript.git","clone_url":"https://github.com/Microsoft/TypeScript.git","svn_url":"https://github.com/Microsoft/TypeScript","homepage":"http://www.typescriptlang.org","size":743857,"stargazers_count":4721,"watchers_count":4721,"language":"TypeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":486,"mirror_url":null,"open_issues_count":570,"forks":486,"open_issues":570,"watchers":4721,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/2843"},"html":{"href":"https://github.com/Microsoft/TypeScript/pull/2843"},"issue":{"href":"https://api.github.com/repos/Microsoft/TypeScript/issues/2843"},"comments":{"href":"https://api.github.com/repos/Microsoft/TypeScript/issues/2843/comments"},"review_comments":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/2843/comments"},"review_comment":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/2843/commits"},"statuses":{"href":"https://api.github.com/repos/Microsoft/TypeScript/statuses/cf00a2bec859eaffa8d82698e57350a149bb2aa4"}}}}