{"action":"created","issue":{"url":"https://api.github.com/repos/jashkenas/coffeescript/issues/4599","repository_url":"https://api.github.com/repos/jashkenas/coffeescript","labels_url":"https://api.github.com/repos/jashkenas/coffeescript/issues/4599/labels{/name}","comments_url":"https://api.github.com/repos/jashkenas/coffeescript/issues/4599/comments","events_url":"https://api.github.com/repos/jashkenas/coffeescript/issues/4599/events","html_url":"https://github.com/jashkenas/coffeescript/pull/4599","id":240075092,"number":4599,"title":"[CS2] Fix #3199: throw multiline implicit object","user":{"login":"helixbass","id":440230,"avatar_url":"https://avatars1.githubusercontent.com/u/440230?v=3","gravatar_id":"","url":"https://api.github.com/users/helixbass","html_url":"https://github.com/helixbass","followers_url":"https://api.github.com/users/helixbass/followers","following_url":"https://api.github.com/users/helixbass/following{/other_user}","gists_url":"https://api.github.com/users/helixbass/gists{/gist_id}","starred_url":"https://api.github.com/users/helixbass/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/helixbass/subscriptions","organizations_url":"https://api.github.com/users/helixbass/orgs","repos_url":"https://api.github.com/users/helixbass/repos","events_url":"https://api.github.com/users/helixbass/events{/privacy}","received_events_url":"https://api.github.com/users/helixbass/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/jashkenas/coffeescript/milestones/10","html_url":"https://github.com/jashkenas/coffeescript/milestone/10","labels_url":"https://api.github.com/repos/jashkenas/coffeescript/milestones/10/labels","id":2015479,"number":10,"title":"2.0.0","description":"A breaking-change release of CoffeeScript that outputs the latest implemented ECMAScript syntax whenever possible.","creator":{"login":"GeoffreyBooth","id":456802,"avatar_url":"https://avatars1.githubusercontent.com/u/456802?v=3","gravatar_id":"","url":"https://api.github.com/users/GeoffreyBooth","html_url":"https://github.com/GeoffreyBooth","followers_url":"https://api.github.com/users/GeoffreyBooth/followers","following_url":"https://api.github.com/users/GeoffreyBooth/following{/other_user}","gists_url":"https://api.github.com/users/GeoffreyBooth/gists{/gist_id}","starred_url":"https://api.github.com/users/GeoffreyBooth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GeoffreyBooth/subscriptions","organizations_url":"https://api.github.com/users/GeoffreyBooth/orgs","repos_url":"https://api.github.com/users/GeoffreyBooth/repos","events_url":"https://api.github.com/users/GeoffreyBooth/events{/privacy}","received_events_url":"https://api.github.com/users/GeoffreyBooth/received_events","type":"User","site_admin":false},"open_issues":7,"closed_issues":61,"state":"open","created_at":"2016-09-20T04:18:33Z","updated_at":"2017-07-09T05:32:03Z","due_on":null,"closed_at":null},"comments":10,"created_at":"2017-07-03T06:07:39Z","updated_at":"2017-07-09T05:38:36Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/jashkenas/coffeescript/pulls/4599","html_url":"https://github.com/jashkenas/coffeescript/pull/4599","diff_url":"https://github.com/jashkenas/coffeescript/pull/4599.diff","patch_url":"https://github.com/jashkenas/coffeescript/pull/4599.patch"},"body":"Fixes #3199 \r\n\r\nThe reason the kind of implicit object \"splitting\" described in #3199 happens is b/c the suppression of the `INDENT` following `throw` doesn't play nicely with the rewriter (`normalizeLines()` specifically). So to me it seems cleaner to preserve the `INDENT` and just add grammar rule `THROW INDENT Expression OUTDENT`\r\n\r\n@GeoffreyBooth this relates to #1263 and your [comment](https://github.com/jashkenas/coffeescript/issues/1263#issuecomment-298253381) there - as you found, `throw` with implicit object worked b/c of `INDENT`/`TERMINATOR` suppression (via `unfinished()`). But then #3199 shows that it doesn't always work. And the same breakage applies to how you implemented `return`ing implicit objects in #4532, ie this breaks:\r\n```\r\nif 1 then return\r\n  a: 1\r\n  b: 2\r\n```\r\nSo I applied the same idea here to `return` and replaced your `INDENT`-suppressing implementation in #4532 with a grammar rule `RETURN INDENT Expression OUTDENT` which un-breaks the above example\r\n\r\nIn a more general way, #3199 and #1263 seem to reflect our feeling that we should be able to pass indented implicit object literals to function-call-ish things like `throw` and `return` the way that we can pass them to an actual function call. I definitely feel that way and am glad that #4532 was added. This PR just changes the way that it's supported to avoid bugs like #3199, I'm unaware if there's any additional downside to doing it via grammar rules allowing `INDENT...OUTDENT` variations\r\n\r\nBut then it does feel a little weird that both how this PR supports it and the existing behavior for `throw` and for `return` (since #4532) allow *anything* to be passed on following lines, not just implicit objects (which is what I think our brains tell us we should be able to do). Eg this has been legal:\r\n```\r\nthrow\r\n  'abc'\r\n```\r\nAnd as of #4532, you can do eg:\r\n```\r\nreturn\r\n  x\r\n```\r\nI don't have a big problem with either of these but it does seem akin to how @jashkenas [apparently](https://github.com/jashkenas/coffeescript/issues/1113#issuecomment-744670) doesn't like the idea of this being legal:\r\n```\r\nfn\r\n  a\r\n```\r\nBecause basically all three of these (`throw`, `return`, and actual function calls) all \"feel\" like function calls, so it would make sense that they follow similar rules\r\n\r\nThere's some interesting related discussion in #3098 and #1263 - [this comment](https://github.com/jashkenas/coffeescript/issues/1263#issuecomment-961570) warns against allowing implicit indented objects with `return` and mentions `throw`, but given that the way it's supported for function calls is different from both existing support for `throw` (which the commenter @satyr added)/`return` (as of #4532) and from how this PR supports it, I'm not inclined to heed it\r\n\r\nPut list of tokens in `UNFINISHED` per @jashkenas' [request](https://github.com/jashkenas/coffeescript/commit/2ea51b02cc9a573a0a9f2b020e49118c2c00fb81#commitcomment-572436)"},"comment":{"url":"https://api.github.com/repos/jashkenas/coffeescript/issues/comments/313900325","html_url":"https://github.com/jashkenas/coffeescript/pull/4599#issuecomment-313900325","issue_url":"https://api.github.com/repos/jashkenas/coffeescript/issues/4599","id":313900325,"user":{"login":"GeoffreyBooth","id":456802,"avatar_url":"https://avatars1.githubusercontent.com/u/456802?v=3","gravatar_id":"","url":"https://api.github.com/users/GeoffreyBooth","html_url":"https://github.com/GeoffreyBooth","followers_url":"https://api.github.com/users/GeoffreyBooth/followers","following_url":"https://api.github.com/users/GeoffreyBooth/following{/other_user}","gists_url":"https://api.github.com/users/GeoffreyBooth/gists{/gist_id}","starred_url":"https://api.github.com/users/GeoffreyBooth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GeoffreyBooth/subscriptions","organizations_url":"https://api.github.com/users/GeoffreyBooth/orgs","repos_url":"https://api.github.com/users/GeoffreyBooth/repos","events_url":"https://api.github.com/users/GeoffreyBooth/events{/privacy}","received_events_url":"https://api.github.com/users/GeoffreyBooth/received_events","type":"User","site_admin":false},"created_at":"2017-07-09T05:38:36Z","updated_at":"2017-07-09T05:38:36Z","body":"@helixbass do you mind answering my last question, and resolving conflicts? Aside from that I think we’re ready to merge."}}
{"actor":{"display_login":"GeoffreyBooth"}}