{"action":"created","issue":{"url":"https://api.github.com/repos/mna/pigeon/issues/66","repository_url":"https://api.github.com/repos/mna/pigeon","labels_url":"https://api.github.com/repos/mna/pigeon/issues/66/labels{/name}","comments_url":"https://api.github.com/repos/mna/pigeon/issues/66/comments","events_url":"https://api.github.com/repos/mna/pigeon/issues/66/events","html_url":"https://github.com/mna/pigeon/pull/66","id":320398325,"number":66,"title":"Fix duplicate function code generation","user":{"login":"mna","id":692384,"avatar_url":"https://avatars2.githubusercontent.com/u/692384?v=4","gravatar_id":"","url":"https://api.github.com/users/mna","html_url":"https://github.com/mna","followers_url":"https://api.github.com/users/mna/followers","following_url":"https://api.github.com/users/mna/following{/other_user}","gists_url":"https://api.github.com/users/mna/gists{/gist_id}","starred_url":"https://api.github.com/users/mna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mna/subscriptions","organizations_url":"https://api.github.com/users/mna/orgs","repos_url":"https://api.github.com/users/mna/repos","events_url":"https://api.github.com/users/mna/events{/privacy}","received_events_url":"https://api.github.com/users/mna/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-05-04T19:24:29Z","updated_at":"2018-05-04T19:28:51Z","closed_at":null,"author_association":"OWNER","pull_request":{"url":"https://api.github.com/repos/mna/pigeon/pulls/66","html_url":"https://github.com/mna/pigeon/pull/66","diff_url":"https://github.com/mna/pigeon/pull/66.diff","patch_url":"https://github.com/mna/pigeon/pull/66.patch"},"body":"This closes #65 .\r\n\r\nAfter optimization with `--optimize-grammar`, a single action (or other code-block-associated expression)  AST node can be used in more than one location. As a result, it gets assigned conflicting `FuncIx` values and, because the builder first generates the grammar AST tree and then generates the code block, the functions get generated more than once with the same name, resulting in build failures on the generated code.\r\n\r\nThis PR makes sure that a given AST node never gets its `FuncIx` overwritten (avoiding the `(*parser).callonList4 undefined` type of errors for the initial `FuncIx` that was subsequently overwritten), and makes sure to render a given function only once (to avoid the `(*current).onList10 redeclared in this block` type of errors).\r\n\r\nAnother approach could be to always clone nodes when optimizing, never assigning any reference, but that would result in code bloat (e.g. the same function body rendered multiple times under different names), and would possibly make the optimization code more complex."},"comment":{"url":"https://api.github.com/repos/mna/pigeon/issues/comments/386708978","html_url":"https://github.com/mna/pigeon/pull/66#issuecomment-386708978","issue_url":"https://api.github.com/repos/mna/pigeon/issues/66","id":386708978,"user":{"login":"mna","id":692384,"avatar_url":"https://avatars2.githubusercontent.com/u/692384?v=4","gravatar_id":"","url":"https://api.github.com/users/mna","html_url":"https://github.com/mna","followers_url":"https://api.github.com/users/mna/followers","following_url":"https://api.github.com/users/mna/following{/other_user}","gists_url":"https://api.github.com/users/mna/gists{/gist_id}","starred_url":"https://api.github.com/users/mna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mna/subscriptions","organizations_url":"https://api.github.com/users/mna/orgs","repos_url":"https://api.github.com/users/mna/repos","events_url":"https://api.github.com/users/mna/events{/privacy}","received_events_url":"https://api.github.com/users/mna/received_events","type":"User","site_admin":false},"created_at":"2018-05-04T19:28:51Z","updated_at":"2018-05-04T19:28:51Z","author_association":"OWNER","body":"Looks like the tests < Go1.7 all fail because the `imports` package now uses the `context` package from the stdlib, which was introduced in Go 1.7. I can update the travis CI file in this PR if you'd like."}}
{"actor":{"display_login":"mna"}}