{"action":"created","issue":{"url":"https://api.github.com/repos/crystal-lang/crystal/issues/2414","repository_url":"https://api.github.com/repos/crystal-lang/crystal","labels_url":"https://api.github.com/repos/crystal-lang/crystal/issues/2414/labels{/name}","comments_url":"https://api.github.com/repos/crystal-lang/crystal/issues/2414/comments","events_url":"https://api.github.com/repos/crystal-lang/crystal/issues/2414/events","html_url":"https://github.com/crystal-lang/crystal/pull/2414","id":145906020,"number":2414,"title":"Block arg '&' dose not always follow no whitespace","user":{"login":"MakeNowJust","id":6679325,"avatar_url":"https://avatars.githubusercontent.com/u/6679325?v=3","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},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-04-05T06:53:42Z","updated_at":"2016-04-05T14:08:45Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/crystal-lang/crystal/pulls/2414","html_url":"https://github.com/crystal-lang/crystal/pull/2414","diff_url":"https://github.com/crystal-lang/crystal/pull/2414.diff","patch_url":"https://github.com/crystal-lang/crystal/pull/2414.patch"},"body":"What no-whitespace check is needed on is only when block arg is passed as first argument and method calling is not wrapped by parentheses, because such a case cannot ditinguish between block arg '&' and binary operator '&'. e.g.\r\n\r\n```crystal\r\nfoo 1, & bar # == foo(1, &bar)\r\nfoo(& bar)   # == foo(&bar)\r\n\r\nfoo & bar    # which dose it mean 'foo(&bar)' or '(foo & bar)'?\r\n             # curretly, it parsed to '(foo & bar)'.\r\n```\r\n\r\nYou may think this fix makes syntax more complex. Don't worry, plus '+' and minus '-' syntax have same complexity already. e.g.\r\n\r\n```crystal\r\nfoo +1  # == foo(+1)\r\nfoo + 1 # == (foo + 1)\r\n```\r\n\r\nCurrent implementation accepts only no-whitespace case, dose not accept following whitespace case. This behavior is different from Ruby, and this change is useful to write some complex expression as block args.\r\n\r\nNote: no-whitespace following check is [here](https://github.com/crystal-lang/crystal/blob/6e6afd4442d2dc0d32643c74931729e892504120/src/compiler/crystal/syntax/parser.cr#L3524-L3525)."},"comment":{"url":"https://api.github.com/repos/crystal-lang/crystal/issues/comments/205825816","html_url":"https://github.com/crystal-lang/crystal/pull/2414#issuecomment-205825816","issue_url":"https://api.github.com/repos/crystal-lang/crystal/issues/2414","id":205825816,"user":{"login":"asterite","id":209371,"avatar_url":"https://avatars.githubusercontent.com/u/209371?v=3","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},"created_at":"2016-04-05T14:08:45Z","updated_at":"2016-04-05T14:08:45Z","body":"Hi @MakeNowJust,\r\n\r\nNot sure about this change. I know space can make a difference (the `+1` case), but I don't see a reason to allow a space before a block argument. The lack of a space between `&` and the next word makes it super obvious that it's a block argument and it's visually more easy to spot.\r\n\r\nWhy do you need this?"}}