{"action":"created","comment":{"url":"https://api.github.com/repos/chapel-lang/chapel/pulls/comments/33491986","id":33491986,"diff_hunk":"@@ -1703,136 +1716,288 @@ static void    buildBreadthFirstModuleList(Vec<ModuleSymbol*>* modules,\n                                            Vec<ModuleSymbol*>* current,\n                                            Vec<ModuleSymbol*>* alreadySeen);\n \n-static Symbol* lookup(BaseAST* scope, const char* name)\n-{\n-  Vec<Symbol*>  symbols;\n+// Given a name and a scope, determine the symbol referred by that name in the\n+// context of that scope.\n+static Symbol* lookup(BaseAST* scope, const char* name) {\n+  Symbol * symbolResult;","path":"compiler/passes/scopeResolve.cpp","position":64,"original_position":64,"commit_id":"6af00c245f7efd59beb091063e93bdd798d01f1b","original_commit_id":"6af00c245f7efd59beb091063e93bdd798d01f1b","user":{"login":"noakesmichael","id":2167206,"avatar_url":"https://avatars.githubusercontent.com/u/2167206?v=3","gravatar_id":"","url":"https://api.github.com/users/noakesmichael","html_url":"https://github.com/noakesmichael","followers_url":"https://api.github.com/users/noakesmichael/followers","following_url":"https://api.github.com/users/noakesmichael/following{/other_user}","gists_url":"https://api.github.com/users/noakesmichael/gists{/gist_id}","starred_url":"https://api.github.com/users/noakesmichael/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/noakesmichael/subscriptions","organizations_url":"https://api.github.com/users/noakesmichael/orgs","repos_url":"https://api.github.com/users/noakesmichael/repos","events_url":"https://api.github.com/users/noakesmichael/events{/privacy}","received_events_url":"https://api.github.com/users/noakesmichael/received_events","type":"User","site_admin":false},"body":"It might be preferred to initialize symbolResult to NULL to ensure that this function never\r\nreturns garbage.  Currently every branch of the body assigns a value to this value but one might\r\nworry about future edits.","created_at":"2015-06-29T17:56:34Z","updated_at":"2015-06-29T17:56:34Z","html_url":"https://github.com/chapel-lang/chapel/pull/2120#discussion_r33491986","pull_request_url":"https://api.github.com/repos/chapel-lang/chapel/pulls/2120","_links":{"self":{"href":"https://api.github.com/repos/chapel-lang/chapel/pulls/comments/33491986"},"html":{"href":"https://github.com/chapel-lang/chapel/pull/2120#discussion_r33491986"},"pull_request":{"href":"https://api.github.com/repos/chapel-lang/chapel/pulls/2120"}}},"pull_request":{"url":"https://api.github.com/repos/chapel-lang/chapel/pulls/2120","id":38690447,"html_url":"https://github.com/chapel-lang/chapel/pull/2120","diff_url":"https://github.com/chapel-lang/chapel/pull/2120.diff","patch_url":"https://github.com/chapel-lang/chapel/pull/2120.patch","issue_url":"https://api.github.com/repos/chapel-lang/chapel/issues/2120","number":2120,"state":"open","locked":false,"title":"Rewrite lookup in scopeResolve pass","user":{"login":"lydia-duncan","id":2454710,"avatar_url":"https://avatars.githubusercontent.com/u/2454710?v=3","gravatar_id":"","url":"https://api.github.com/users/lydia-duncan","html_url":"https://github.com/lydia-duncan","followers_url":"https://api.github.com/users/lydia-duncan/followers","following_url":"https://api.github.com/users/lydia-duncan/following{/other_user}","gists_url":"https://api.github.com/users/lydia-duncan/gists{/gist_id}","starred_url":"https://api.github.com/users/lydia-duncan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lydia-duncan/subscriptions","organizations_url":"https://api.github.com/users/lydia-duncan/orgs","repos_url":"https://api.github.com/users/lydia-duncan/repos","events_url":"https://api.github.com/users/lydia-duncan/events{/privacy}","received_events_url":"https://api.github.com/users/lydia-duncan/received_events","type":"User","site_admin":false},"body":"The lookup function in scopeResolve had a couple of errors in it related\r\nto precedence of symbols.  Most of them were exhibited when deciding\r\nbetween methods and functions, the result of which would be discarded\r\nand recalculated in function resolution, several passes later.  However,\r\nthere were cases where a method was deemed a match when the\r\nmethod was not applicable to the call scope (i.e. we found and accepted\r\nC.foo because we were given just the name \"foo\" to look for, but we\r\nweren't in a method on C) and an outer scope defined a variable which\r\nwas shadowed by this early and incorrect match.  This behavior was\r\nnoticed in the futures test/modules/bradc/useFileSystemShadowsPath\r\nand test/modules/diten/module_use_hides_size_var.  In a similar vein,\r\nwe allowed users to define function arguments that were shadowed by\r\nused module level variables without comment - an example of this\r\nbehavior is found in test/modules/diten/moduleShadowsFormal and in\r\ntest/studies/graph500/v2/scalableDataGenerator (used by main.chpl).\r\nAnd though Chapel is a single namespace language, there were instances\r\nwhere module names could be shared with sibling function names.  It\r\nwas also posited that we could more efficiently resolve accesses of the\r\nform M1.[Mn.]*var by looking for all the symbols at once and as they\r\nrelate to each other (though we are not certain if this would be better\r\nor worse).\r\n\r\nWith these thoughts in mind, I have undertaken to rewrite and improve\r\nthe lookup function and its helpers.  Some of the functionality remains\r\nunaltered, while the remainder has been examined to ensure that the\r\noutput is now the same as or better than the older version.  The\r\naforementioned futures now pass (I will remove them after a night of\r\ntesting), when a module level variable shadows a formal we now emit\r\na warning, and I have added a test ensuring that sibling modules and\r\nfunctions now cannot share a name.  I have removed a future with code\r\nthat was similar to moduleShadowsFormal but expected a different\r\noutcome.\r\n\r\nWhen looking at this change, it is best to view the old and new lookup\r\nside by side, as the diff is difficult to read otherwise.","created_at":"2015-06-26T21:19:02Z","updated_at":"2015-06-29T17:56:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b72581c0d32fda44ff5ed727603ef3c38c703ccd","assignee":{"login":"noakesmichael","id":2167206,"avatar_url":"https://avatars.githubusercontent.com/u/2167206?v=3","gravatar_id":"","url":"https://api.github.com/users/noakesmichael","html_url":"https://github.com/noakesmichael","followers_url":"https://api.github.com/users/noakesmichael/followers","following_url":"https://api.github.com/users/noakesmichael/following{/other_user}","gists_url":"https://api.github.com/users/noakesmichael/gists{/gist_id}","starred_url":"https://api.github.com/users/noakesmichael/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/noakesmichael/subscriptions","organizations_url":"https://api.github.com/users/noakesmichael/orgs","repos_url":"https://api.github.com/users/noakesmichael/repos","events_url":"https://api.github.com/users/noakesmichael/events{/privacy}","received_events_url":"https://api.github.com/users/noakesmichael/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/chapel-lang/chapel/pulls/2120/commits","review_comments_url":"https://api.github.com/repos/chapel-lang/chapel/pulls/2120/comments","review_comment_url":"https://api.github.com/repos/chapel-lang/chapel/pulls/comments{/number}","comments_url":"https://api.github.com/repos/chapel-lang/chapel/issues/2120/comments","statuses_url":"https://api.github.com/repos/chapel-lang/chapel/statuses/6af00c245f7efd59beb091063e93bdd798d01f1b","head":{"label":"lydia-duncan:rewriteWithoutDescendingMachinery","ref":"rewriteWithoutDescendingMachinery","sha":"6af00c245f7efd59beb091063e93bdd798d01f1b","user":{"login":"lydia-duncan","id":2454710,"avatar_url":"https://avatars.githubusercontent.com/u/2454710?v=3","gravatar_id":"","url":"https://api.github.com/users/lydia-duncan","html_url":"https://github.com/lydia-duncan","followers_url":"https://api.github.com/users/lydia-duncan/followers","following_url":"https://api.github.com/users/lydia-duncan/following{/other_user}","gists_url":"https://api.github.com/users/lydia-duncan/gists{/gist_id}","starred_url":"https://api.github.com/users/lydia-duncan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lydia-duncan/subscriptions","organizations_url":"https://api.github.com/users/lydia-duncan/orgs","repos_url":"https://api.github.com/users/lydia-duncan/repos","events_url":"https://api.github.com/users/lydia-duncan/events{/privacy}","received_events_url":"https://api.github.com/users/lydia-duncan/received_events","type":"User","site_admin":false},"repo":{"id":21914939,"name":"chapel","full_name":"lydia-duncan/chapel","owner":{"login":"lydia-duncan","id":2454710,"avatar_url":"https://avatars.githubusercontent.com/u/2454710?v=3","gravatar_id":"","url":"https://api.github.com/users/lydia-duncan","html_url":"https://github.com/lydia-duncan","followers_url":"https://api.github.com/users/lydia-duncan/followers","following_url":"https://api.github.com/users/lydia-duncan/following{/other_user}","gists_url":"https://api.github.com/users/lydia-duncan/gists{/gist_id}","starred_url":"https://api.github.com/users/lydia-duncan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lydia-duncan/subscriptions","organizations_url":"https://api.github.com/users/lydia-duncan/orgs","repos_url":"https://api.github.com/users/lydia-duncan/repos","events_url":"https://api.github.com/users/lydia-duncan/events{/privacy}","received_events_url":"https://api.github.com/users/lydia-duncan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lydia-duncan/chapel","description":"a Productive Parallel Programming Language","fork":true,"url":"https://api.github.com/repos/lydia-duncan/chapel","forks_url":"https://api.github.com/repos/lydia-duncan/chapel/forks","keys_url":"https://api.github.com/repos/lydia-duncan/chapel/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lydia-duncan/chapel/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lydia-duncan/chapel/teams","hooks_url":"https://api.github.com/repos/lydia-duncan/chapel/hooks","issue_events_url":"https://api.github.com/repos/lydia-duncan/chapel/issues/events{/number}","events_url":"https://api.github.com/repos/lydia-duncan/chapel/events","assignees_url":"https://api.github.com/repos/lydia-duncan/chapel/assignees{/user}","branches_url":"https://api.github.com/repos/lydia-duncan/chapel/branches{/branch}","tags_url":"https://api.github.com/repos/lydia-duncan/chapel/tags","blobs_url":"https://api.github.com/repos/lydia-duncan/chapel/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lydia-duncan/chapel/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lydia-duncan/chapel/git/refs{/sha}","trees_url":"https://api.github.com/repos/lydia-duncan/chapel/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lydia-duncan/chapel/statuses/{sha}","languages_url":"https://api.github.com/repos/lydia-duncan/chapel/languages","stargazers_url":"https://api.github.com/repos/lydia-duncan/chapel/stargazers","contributors_url":"https://api.github.com/repos/lydia-duncan/chapel/contributors","subscribers_url":"https://api.github.com/repos/lydia-duncan/chapel/subscribers","subscription_url":"https://api.github.com/repos/lydia-duncan/chapel/subscription","commits_url":"https://api.github.com/repos/lydia-duncan/chapel/commits{/sha}","git_commits_url":"https://api.github.com/repos/lydia-duncan/chapel/git/commits{/sha}","comments_url":"https://api.github.com/repos/lydia-duncan/chapel/comments{/number}","issue_comment_url":"https://api.github.com/repos/lydia-duncan/chapel/issues/comments{/number}","contents_url":"https://api.github.com/repos/lydia-duncan/chapel/contents/{+path}","compare_url":"https://api.github.com/repos/lydia-duncan/chapel/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lydia-duncan/chapel/merges","archive_url":"https://api.github.com/repos/lydia-duncan/chapel/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lydia-duncan/chapel/downloads","issues_url":"https://api.github.com/repos/lydia-duncan/chapel/issues{/number}","pulls_url":"https://api.github.com/repos/lydia-duncan/chapel/pulls{/number}","milestones_url":"https://api.github.com/repos/lydia-duncan/chapel/milestones{/number}","notifications_url":"https://api.github.com/repos/lydia-duncan/chapel/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lydia-duncan/chapel/labels{/name}","releases_url":"https://api.github.com/repos/lydia-duncan/chapel/releases{/id}","created_at":"2014-07-16T19:55:13Z","updated_at":"2015-05-07T22:40:02Z","pushed_at":"2015-06-29T15:46:42Z","git_url":"git://github.com/lydia-duncan/chapel.git","ssh_url":"git@github.com:lydia-duncan/chapel.git","clone_url":"https://github.com/lydia-duncan/chapel.git","svn_url":"https://github.com/lydia-duncan/chapel","homepage":"http://chapel.cray.com/","size":297616,"stargazers_count":1,"watchers_count":1,"language":"Chapel","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"chapel-lang:master","ref":"master","sha":"7a5f76ec91c31ac7b7f6e6d2c5fba82de84e086a","user":{"login":"chapel-lang","id":7597261,"avatar_url":"https://avatars.githubusercontent.com/u/7597261?v=3","gravatar_id":"","url":"https://api.github.com/users/chapel-lang","html_url":"https://github.com/chapel-lang","followers_url":"https://api.github.com/users/chapel-lang/followers","following_url":"https://api.github.com/users/chapel-lang/following{/other_user}","gists_url":"https://api.github.com/users/chapel-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/chapel-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chapel-lang/subscriptions","organizations_url":"https://api.github.com/users/chapel-lang/orgs","repos_url":"https://api.github.com/users/chapel-lang/repos","events_url":"https://api.github.com/users/chapel-lang/events{/privacy}","received_events_url":"https://api.github.com/users/chapel-lang/received_events","type":"Organization","site_admin":false},"repo":{"id":21663285,"name":"chapel","full_name":"chapel-lang/chapel","owner":{"login":"chapel-lang","id":7597261,"avatar_url":"https://avatars.githubusercontent.com/u/7597261?v=3","gravatar_id":"","url":"https://api.github.com/users/chapel-lang","html_url":"https://github.com/chapel-lang","followers_url":"https://api.github.com/users/chapel-lang/followers","following_url":"https://api.github.com/users/chapel-lang/following{/other_user}","gists_url":"https://api.github.com/users/chapel-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/chapel-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chapel-lang/subscriptions","organizations_url":"https://api.github.com/users/chapel-lang/orgs","repos_url":"https://api.github.com/users/chapel-lang/repos","events_url":"https://api.github.com/users/chapel-lang/events{/privacy}","received_events_url":"https://api.github.com/users/chapel-lang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/chapel-lang/chapel","description":"a Productive Parallel Programming Language","fork":false,"url":"https://api.github.com/repos/chapel-lang/chapel","forks_url":"https://api.github.com/repos/chapel-lang/chapel/forks","keys_url":"https://api.github.com/repos/chapel-lang/chapel/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chapel-lang/chapel/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chapel-lang/chapel/teams","hooks_url":"https://api.github.com/repos/chapel-lang/chapel/hooks","issue_events_url":"https://api.github.com/repos/chapel-lang/chapel/issues/events{/number}","events_url":"https://api.github.com/repos/chapel-lang/chapel/events","assignees_url":"https://api.github.com/repos/chapel-lang/chapel/assignees{/user}","branches_url":"https://api.github.com/repos/chapel-lang/chapel/branches{/branch}","tags_url":"https://api.github.com/repos/chapel-lang/chapel/tags","blobs_url":"https://api.github.com/repos/chapel-lang/chapel/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chapel-lang/chapel/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chapel-lang/chapel/git/refs{/sha}","trees_url":"https://api.github.com/repos/chapel-lang/chapel/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chapel-lang/chapel/statuses/{sha}","languages_url":"https://api.github.com/repos/chapel-lang/chapel/languages","stargazers_url":"https://api.github.com/repos/chapel-lang/chapel/stargazers","contributors_url":"https://api.github.com/repos/chapel-lang/chapel/contributors","subscribers_url":"https://api.github.com/repos/chapel-lang/chapel/subscribers","subscription_url":"https://api.github.com/repos/chapel-lang/chapel/subscription","commits_url":"https://api.github.com/repos/chapel-lang/chapel/commits{/sha}","git_commits_url":"https://api.github.com/repos/chapel-lang/chapel/git/commits{/sha}","comments_url":"https://api.github.com/repos/chapel-lang/chapel/comments{/number}","issue_comment_url":"https://api.github.com/repos/chapel-lang/chapel/issues/comments{/number}","contents_url":"https://api.github.com/repos/chapel-lang/chapel/contents/{+path}","compare_url":"https://api.github.com/repos/chapel-lang/chapel/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chapel-lang/chapel/merges","archive_url":"https://api.github.com/repos/chapel-lang/chapel/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chapel-lang/chapel/downloads","issues_url":"https://api.github.com/repos/chapel-lang/chapel/issues{/number}","pulls_url":"https://api.github.com/repos/chapel-lang/chapel/pulls{/number}","milestones_url":"https://api.github.com/repos/chapel-lang/chapel/milestones{/number}","notifications_url":"https://api.github.com/repos/chapel-lang/chapel/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chapel-lang/chapel/labels{/name}","releases_url":"https://api.github.com/repos/chapel-lang/chapel/releases{/id}","created_at":"2014-07-09T18:15:54Z","updated_at":"2015-06-29T15:40:26Z","pushed_at":"2015-06-29T17:39:40Z","git_url":"git://github.com/chapel-lang/chapel.git","ssh_url":"git@github.com:chapel-lang/chapel.git","clone_url":"https://github.com/chapel-lang/chapel.git","svn_url":"https://github.com/chapel-lang/chapel","homepage":"http://chapel.cray.com/","size":432219,"stargazers_count":122,"watchers_count":122,"language":"Chapel","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":46,"mirror_url":null,"open_issues_count":3,"forks":46,"open_issues":3,"watchers":122,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/chapel-lang/chapel/pulls/2120"},"html":{"href":"https://github.com/chapel-lang/chapel/pull/2120"},"issue":{"href":"https://api.github.com/repos/chapel-lang/chapel/issues/2120"},"comments":{"href":"https://api.github.com/repos/chapel-lang/chapel/issues/2120/comments"},"review_comments":{"href":"https://api.github.com/repos/chapel-lang/chapel/pulls/2120/comments"},"review_comment":{"href":"https://api.github.com/repos/chapel-lang/chapel/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/chapel-lang/chapel/pulls/2120/commits"},"statuses":{"href":"https://api.github.com/repos/chapel-lang/chapel/statuses/6af00c245f7efd59beb091063e93bdd798d01f1b"}}}}