{"action":"created","comment":{"url":"https://api.github.com/repos/crystal-lang/crystal/pulls/comments/229322218","pull_request_review_id":169793923,"id":229322218,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyOTMyMjIxOA==","diff_hunk":"@@ -26,6 +26,33 @@ module Crystal\n     # Heredocs pushed when found. Should be processed when encountering a newline\n     getter heredocs = [] of {Token::DelimiterState, HeredocItem}\n \n+    property invisible_loc_pragmas : Hash(Int32, Array(LocPragma))? = nil\n+\n+    alias LocPragma = LocStackPragma | LocSetPragma\n+\n+    enum LocStackPragma","path":"src/compiler/crystal/syntax/lexer.cr","position":8,"original_position":8,"commit_id":"870c8bc61b8a80d8b489b0d773b7cf7dd64e08c5","original_commit_id":"870c8bc61b8a80d8b489b0d773b7cf7dd64e08c5","user":{"login":"asterite","id":209371,"node_id":"MDQ6VXNlcjIwOTM3MQ==","avatar_url":"https://avatars0.githubusercontent.com/u/209371?v=4","gravatar_id":"","url":"https://api.github.com/users/asterite","html_url":"https://github.com/asterite","followers_url":"https://api.github.com/users/asterite/followers","following_url":"https://api.github.com/users/asterite/following{/other_user}","gists_url":"https://api.github.com/users/asterite/gists{/gist_id}","starred_url":"https://api.github.com/users/asterite/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asterite/subscriptions","organizations_url":"https://api.github.com/users/asterite/orgs","repos_url":"https://api.github.com/users/asterite/repos","events_url":"https://api.github.com/users/asterite/events{/privacy}","received_events_url":"https://api.github.com/users/asterite/received_events","type":"User","site_admin":false},"body":"What do you think if we separate this into two types? It can be `LocPushPragma` and `LocPopPragma`. Maybe the code will be even smaller. And the `case` bellow will be \"complete\" (right now there's a hidden `else`)","created_at":"2018-10-30T14:12:51Z","updated_at":"2018-10-30T14:12:51Z","html_url":"https://github.com/crystal-lang/crystal/pull/7008#discussion_r229322218","pull_request_url":"https://api.github.com/repos/crystal-lang/crystal/pulls/7008","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/crystal-lang/crystal/pulls/comments/229322218"},"html":{"href":"https://github.com/crystal-lang/crystal/pull/7008#discussion_r229322218"},"pull_request":{"href":"https://api.github.com/repos/crystal-lang/crystal/pulls/7008"}}},"pull_request":{"url":"https://api.github.com/repos/crystal-lang/crystal/pulls/7008","id":226809854,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI2ODA5ODU0","html_url":"https://github.com/crystal-lang/crystal/pull/7008","diff_url":"https://github.com/crystal-lang/crystal/pull/7008.diff","patch_url":"https://github.com/crystal-lang/crystal/pull/7008.patch","issue_url":"https://api.github.com/repos/crystal-lang/crystal/issues/7008","number":7008,"state":"open","locked":false,"title":"Compiler: add locations to all expanded macro arguments","user":{"login":"MakeNowJust","id":6679325,"node_id":"MDQ6VXNlcjY2NzkzMjU=","avatar_url":"https://avatars3.githubusercontent.com/u/6679325?v=4","gravatar_id":"","url":"https://api.github.com/users/MakeNowJust","html_url":"https://github.com/MakeNowJust","followers_url":"https://api.github.com/users/MakeNowJust/followers","following_url":"https://api.github.com/users/MakeNowJust/following{/other_user}","gists_url":"https://api.github.com/users/MakeNowJust/gists{/gist_id}","starred_url":"https://api.github.com/users/MakeNowJust/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MakeNowJust/subscriptions","organizations_url":"https://api.github.com/users/MakeNowJust/orgs","repos_url":"https://api.github.com/users/MakeNowJust/repos","events_url":"https://api.github.com/users/MakeNowJust/events{/privacy}","received_events_url":"https://api.github.com/users/MakeNowJust/received_events","type":"User","site_admin":false},"body":"This PR changes compiler to add locations to all expanded macro arguments if possible. It makes helpful error message on macro expansion.\r\n\r\nFor example the following code makes an error with message `undefined constant BadType`.\r\n\r\n```crystal\r\nclass Foo\r\n  getter foo : BadType\r\nend\r\n```\r\n\r\nHowever, currently the compiler shows expanded macro code and reports expanded macro line as error location. It is confusing for Crystal beginners I think.\r\n\r\n```console\r\n$ crystal run foo.cr\r\nError in foo.cr:2: expanding macro\r\n\r\n  getter foo : BadType\r\n  ^~~~~~\r\n\r\nin foo.cr:2: expanding macro\r\n\r\n  getter foo : BadType\r\n  ^\r\n\r\nin macro 'getter' expanded macro: macro_4384842512:113, line 4:\r\n\r\n   1.\r\n   2.\r\n   3.\r\n>  4.             @foo : BadType\r\n   5.\r\n   6.             def foo : BadType\r\n   7.               @foo\r\n   8.             end\r\n   9.\r\n  10.\r\n  11.\r\n  12.\r\n\r\nundefined constant BadType\r\n```\r\n\r\nAfter this PR, the compiler shows such a simple error:\r\n\r\n```console\r\n$ bin/crystal foo.cr\r\nError in foo.cr:2: expanding macro\r\n\r\n  getter foo : BadType\r\n  ^~~~~~\r\n\r\nin foo.cr:2: undefined constant BadType\r\n\r\n  getter foo : BadType\r\n               ^~~~~~~\r\n\r\n```\r\n\r\nGreat!\r\n\r\n- - -\r\n\r\n## Technical Note\r\n\r\nI believe this PR is awesome and useful, however, some developers (especially compiler specialist @asterite) think it is unacceptable because emitting location pragmas more makes breaking change and they know it is unuseful in some cases. (ref. #3858)\r\n\r\nDon't worry! This PR does not add emitting location pragmas actually. Instead of emitting location pragmas to expanded code, it saves a pair of expanded code position and location pragmas of its position on macro expansion (it is called as `invisible_loc_pragmas` in source code.), and the lexer processes this data on parsing expanded code. It is cleaner and better than embedding location pragmas.\r\n(However we cannot remove location pragmas from language because it has use-case still, e.g. ECR)\r\n\r\n- - -\r\n\r\n@bew This PR solves #6125 indirectly. What do you think?\r\n\r\n- - -\r\n\r\nThank you :smile:","created_at":"2018-10-30T06:52:08Z","updated_at":"2018-10-30T14:12:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"eb88b2afb9afe4c101531959ef4b3296b3775b23","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/crystal-lang/crystal/pulls/7008/commits","review_comments_url":"https://api.github.com/repos/crystal-lang/crystal/pulls/7008/comments","review_comment_url":"https://api.github.com/repos/crystal-lang/crystal/pulls/comments{/number}","comments_url":"https://api.github.com/repos/crystal-lang/crystal/issues/7008/comments","statuses_url":"https://api.github.com/repos/crystal-lang/crystal/statuses/870c8bc61b8a80d8b489b0d773b7cf7dd64e08c5","head":{"label":"MakeNowJust:feature/add-location-to-all-expanded-macro-args","ref":"feature/add-location-to-all-expanded-macro-args","sha":"870c8bc61b8a80d8b489b0d773b7cf7dd64e08c5","user":{"login":"MakeNowJust","id":6679325,"node_id":"MDQ6VXNlcjY2NzkzMjU=","avatar_url":"https://avatars3.githubusercontent.com/u/6679325?v=4","gravatar_id":"","url":"https://api.github.com/users/MakeNowJust","html_url":"https://github.com/MakeNowJust","followers_url":"https://api.github.com/users/MakeNowJust/followers","following_url":"https://api.github.com/users/MakeNowJust/following{/other_user}","gists_url":"https://api.github.com/users/MakeNowJust/gists{/gist_id}","starred_url":"https://api.github.com/users/MakeNowJust/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MakeNowJust/subscriptions","organizations_url":"https://api.github.com/users/MakeNowJust/orgs","repos_url":"https://api.github.com/users/MakeNowJust/repos","events_url":"https://api.github.com/users/MakeNowJust/events{/privacy}","received_events_url":"https://api.github.com/users/MakeNowJust/received_events","type":"User","site_admin":false},"repo":{"id":38912767,"node_id":"MDEwOlJlcG9zaXRvcnkzODkxMjc2Nw==","name":"crystal","full_name":"MakeNowJust/crystal","private":false,"owner":{"login":"MakeNowJust","id":6679325,"node_id":"MDQ6VXNlcjY2NzkzMjU=","avatar_url":"https://avatars3.githubusercontent.com/u/6679325?v=4","gravatar_id":"","url":"https://api.github.com/users/MakeNowJust","html_url":"https://github.com/MakeNowJust","followers_url":"https://api.github.com/users/MakeNowJust/followers","following_url":"https://api.github.com/users/MakeNowJust/following{/other_user}","gists_url":"https://api.github.com/users/MakeNowJust/gists{/gist_id}","starred_url":"https://api.github.com/users/MakeNowJust/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MakeNowJust/subscriptions","organizations_url":"https://api.github.com/users/MakeNowJust/orgs","repos_url":"https://api.github.com/users/MakeNowJust/repos","events_url":"https://api.github.com/users/MakeNowJust/events{/privacy}","received_events_url":"https://api.github.com/users/MakeNowJust/received_events","type":"User","site_admin":false},"html_url":"https://github.com/MakeNowJust/crystal","description":"The Crystal Programming Language","fork":true,"url":"https://api.github.com/repos/MakeNowJust/crystal","forks_url":"https://api.github.com/repos/MakeNowJust/crystal/forks","keys_url":"https://api.github.com/repos/MakeNowJust/crystal/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MakeNowJust/crystal/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MakeNowJust/crystal/teams","hooks_url":"https://api.github.com/repos/MakeNowJust/crystal/hooks","issue_events_url":"https://api.github.com/repos/MakeNowJust/crystal/issues/events{/number}","events_url":"https://api.github.com/repos/MakeNowJust/crystal/events","assignees_url":"https://api.github.com/repos/MakeNowJust/crystal/assignees{/user}","branches_url":"https://api.github.com/repos/MakeNowJust/crystal/branches{/branch}","tags_url":"https://api.github.com/repos/MakeNowJust/crystal/tags","blobs_url":"https://api.github.com/repos/MakeNowJust/crystal/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MakeNowJust/crystal/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MakeNowJust/crystal/git/refs{/sha}","trees_url":"https://api.github.com/repos/MakeNowJust/crystal/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MakeNowJust/crystal/statuses/{sha}","languages_url":"https://api.github.com/repos/MakeNowJust/crystal/languages","stargazers_url":"https://api.github.com/repos/MakeNowJust/crystal/stargazers","contributors_url":"https://api.github.com/repos/MakeNowJust/crystal/contributors","subscribers_url":"https://api.github.com/repos/MakeNowJust/crystal/subscribers","subscription_url":"https://api.github.com/repos/MakeNowJust/crystal/subscription","commits_url":"https://api.github.com/repos/MakeNowJust/crystal/commits{/sha}","git_commits_url":"https://api.github.com/repos/MakeNowJust/crystal/git/commits{/sha}","comments_url":"https://api.github.com/repos/MakeNowJust/crystal/comments{/number}","issue_comment_url":"https://api.github.com/repos/MakeNowJust/crystal/issues/comments{/number}","contents_url":"https://api.github.com/repos/MakeNowJust/crystal/contents/{+path}","compare_url":"https://api.github.com/repos/MakeNowJust/crystal/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MakeNowJust/crystal/merges","archive_url":"https://api.github.com/repos/MakeNowJust/crystal/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MakeNowJust/crystal/downloads","issues_url":"https://api.github.com/repos/MakeNowJust/crystal/issues{/number}","pulls_url":"https://api.github.com/repos/MakeNowJust/crystal/pulls{/number}","milestones_url":"https://api.github.com/repos/MakeNowJust/crystal/milestones{/number}","notifications_url":"https://api.github.com/repos/MakeNowJust/crystal/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MakeNowJust/crystal/labels{/name}","releases_url":"https://api.github.com/repos/MakeNowJust/crystal/releases{/id}","deployments_url":"https://api.github.com/repos/MakeNowJust/crystal/deployments","created_at":"2015-07-11T03:48:50Z","updated_at":"2018-10-28T23:13:27Z","pushed_at":"2018-10-30T06:21:26Z","git_url":"git://github.com/MakeNowJust/crystal.git","ssh_url":"git@github.com:MakeNowJust/crystal.git","clone_url":"https://github.com/MakeNowJust/crystal.git","svn_url":"https://github.com/MakeNowJust/crystal","homepage":"http://crystal-lang.org","size":45393,"stargazers_count":1,"watchers_count":1,"language":"Crystal","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"crystal-lang:master","ref":"master","sha":"9d6fc90b71ca7d85c225b414dd4a7385a04bc13f","user":{"login":"crystal-lang","id":6539796,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY1Mzk3OTY=","avatar_url":"https://avatars0.githubusercontent.com/u/6539796?v=4","gravatar_id":"","url":"https://api.github.com/users/crystal-lang","html_url":"https://github.com/crystal-lang","followers_url":"https://api.github.com/users/crystal-lang/followers","following_url":"https://api.github.com/users/crystal-lang/following{/other_user}","gists_url":"https://api.github.com/users/crystal-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/crystal-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crystal-lang/subscriptions","organizations_url":"https://api.github.com/users/crystal-lang/orgs","repos_url":"https://api.github.com/users/crystal-lang/repos","events_url":"https://api.github.com/users/crystal-lang/events{/privacy}","received_events_url":"https://api.github.com/users/crystal-lang/received_events","type":"Organization","site_admin":false},"repo":{"id":6887813,"node_id":"MDEwOlJlcG9zaXRvcnk2ODg3ODEz","name":"crystal","full_name":"crystal-lang/crystal","private":false,"owner":{"login":"crystal-lang","id":6539796,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY1Mzk3OTY=","avatar_url":"https://avatars0.githubusercontent.com/u/6539796?v=4","gravatar_id":"","url":"https://api.github.com/users/crystal-lang","html_url":"https://github.com/crystal-lang","followers_url":"https://api.github.com/users/crystal-lang/followers","following_url":"https://api.github.com/users/crystal-lang/following{/other_user}","gists_url":"https://api.github.com/users/crystal-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/crystal-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crystal-lang/subscriptions","organizations_url":"https://api.github.com/users/crystal-lang/orgs","repos_url":"https://api.github.com/users/crystal-lang/repos","events_url":"https://api.github.com/users/crystal-lang/events{/privacy}","received_events_url":"https://api.github.com/users/crystal-lang/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/crystal-lang/crystal","description":"The Crystal Programming Language","fork":false,"url":"https://api.github.com/repos/crystal-lang/crystal","forks_url":"https://api.github.com/repos/crystal-lang/crystal/forks","keys_url":"https://api.github.com/repos/crystal-lang/crystal/keys{/key_id}","collaborators_url":"https://api.github.com/repos/crystal-lang/crystal/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/crystal-lang/crystal/teams","hooks_url":"https://api.github.com/repos/crystal-lang/crystal/hooks","issue_events_url":"https://api.github.com/repos/crystal-lang/crystal/issues/events{/number}","events_url":"https://api.github.com/repos/crystal-lang/crystal/events","assignees_url":"https://api.github.com/repos/crystal-lang/crystal/assignees{/user}","branches_url":"https://api.github.com/repos/crystal-lang/crystal/branches{/branch}","tags_url":"https://api.github.com/repos/crystal-lang/crystal/tags","blobs_url":"https://api.github.com/repos/crystal-lang/crystal/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/crystal-lang/crystal/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/crystal-lang/crystal/git/refs{/sha}","trees_url":"https://api.github.com/repos/crystal-lang/crystal/git/trees{/sha}","statuses_url":"https://api.github.com/repos/crystal-lang/crystal/statuses/{sha}","languages_url":"https://api.github.com/repos/crystal-lang/crystal/languages","stargazers_url":"https://api.github.com/repos/crystal-lang/crystal/stargazers","contributors_url":"https://api.github.com/repos/crystal-lang/crystal/contributors","subscribers_url":"https://api.github.com/repos/crystal-lang/crystal/subscribers","subscription_url":"https://api.github.com/repos/crystal-lang/crystal/subscription","commits_url":"https://api.github.com/repos/crystal-lang/crystal/commits{/sha}","git_commits_url":"https://api.github.com/repos/crystal-lang/crystal/git/commits{/sha}","comments_url":"https://api.github.com/repos/crystal-lang/crystal/comments{/number}","issue_comment_url":"https://api.github.com/repos/crystal-lang/crystal/issues/comments{/number}","contents_url":"https://api.github.com/repos/crystal-lang/crystal/contents/{+path}","compare_url":"https://api.github.com/repos/crystal-lang/crystal/compare/{base}...{head}","merges_url":"https://api.github.com/repos/crystal-lang/crystal/merges","archive_url":"https://api.github.com/repos/crystal-lang/crystal/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/crystal-lang/crystal/downloads","issues_url":"https://api.github.com/repos/crystal-lang/crystal/issues{/number}","pulls_url":"https://api.github.com/repos/crystal-lang/crystal/pulls{/number}","milestones_url":"https://api.github.com/repos/crystal-lang/crystal/milestones{/number}","notifications_url":"https://api.github.com/repos/crystal-lang/crystal/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/crystal-lang/crystal/labels{/name}","releases_url":"https://api.github.com/repos/crystal-lang/crystal/releases{/id}","deployments_url":"https://api.github.com/repos/crystal-lang/crystal/deployments","created_at":"2012-11-27T17:32:32Z","updated_at":"2018-10-30T14:10:11Z","pushed_at":"2018-10-30T10:17:24Z","git_url":"git://github.com/crystal-lang/crystal.git","ssh_url":"git@github.com:crystal-lang/crystal.git","clone_url":"https://github.com/crystal-lang/crystal.git","svn_url":"https://github.com/crystal-lang/crystal","homepage":"https://crystal-lang.org","size":37465,"stargazers_count":12103,"watchers_count":12103,"language":"Crystal","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":942,"mirror_url":null,"archived":false,"open_issues_count":747,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":942,"open_issues":747,"watchers":12103,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/crystal-lang/crystal/pulls/7008"},"html":{"href":"https://github.com/crystal-lang/crystal/pull/7008"},"issue":{"href":"https://api.github.com/repos/crystal-lang/crystal/issues/7008"},"comments":{"href":"https://api.github.com/repos/crystal-lang/crystal/issues/7008/comments"},"review_comments":{"href":"https://api.github.com/repos/crystal-lang/crystal/pulls/7008/comments"},"review_comment":{"href":"https://api.github.com/repos/crystal-lang/crystal/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/crystal-lang/crystal/pulls/7008/commits"},"statuses":{"href":"https://api.github.com/repos/crystal-lang/crystal/statuses/870c8bc61b8a80d8b489b0d773b7cf7dd64e08c5"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"asterite"}}