{"action":"created","issue":{"url":"https://api.github.com/repos/sandstorm-io/capnproto/issues/257","labels_url":"https://api.github.com/repos/sandstorm-io/capnproto/issues/257/labels{/name}","comments_url":"https://api.github.com/repos/sandstorm-io/capnproto/issues/257/comments","events_url":"https://api.github.com/repos/sandstorm-io/capnproto/issues/257/events","html_url":"https://github.com/sandstorm-io/capnproto/issues/257","id":115124773,"number":257,"title":"Named unions / groups inside generic structs cause compiler error","user":{"login":"kentonv","id":4001805,"avatar_url":"https://avatars.githubusercontent.com/u/4001805?v=3","gravatar_id":"","url":"https://api.github.com/users/kentonv","html_url":"https://github.com/kentonv","followers_url":"https://api.github.com/users/kentonv/followers","following_url":"https://api.github.com/users/kentonv/following{/other_user}","gists_url":"https://api.github.com/users/kentonv/gists{/gist_id}","starred_url":"https://api.github.com/users/kentonv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kentonv/subscriptions","organizations_url":"https://api.github.com/users/kentonv/orgs","repos_url":"https://api.github.com/users/kentonv/repos","events_url":"https://api.github.com/users/kentonv/events{/privacy}","received_events_url":"https://api.github.com/users/kentonv/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-11-04T19:05:24Z","updated_at":"2015-11-05T21:36:07Z","closed_at":null,"body":"The generated code needs some additional `typename` keywords."},"comment":{"url":"https://api.github.com/repos/sandstorm-io/capnproto/issues/comments/154200150","html_url":"https://github.com/sandstorm-io/capnproto/issues/257#issuecomment-154200150","issue_url":"https://api.github.com/repos/sandstorm-io/capnproto/issues/257","id":154200150,"user":{"login":"thomasmarsh","id":2229467,"avatar_url":"https://avatars.githubusercontent.com/u/2229467?v=3","gravatar_id":"","url":"https://api.github.com/users/thomasmarsh","html_url":"https://github.com/thomasmarsh","followers_url":"https://api.github.com/users/thomasmarsh/followers","following_url":"https://api.github.com/users/thomasmarsh/following{/other_user}","gists_url":"https://api.github.com/users/thomasmarsh/gists{/gist_id}","starred_url":"https://api.github.com/users/thomasmarsh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thomasmarsh/subscriptions","organizations_url":"https://api.github.com/users/thomasmarsh/orgs","repos_url":"https://api.github.com/users/thomasmarsh/repos","events_url":"https://api.github.com/users/thomasmarsh/events{/privacy}","received_events_url":"https://api.github.com/users/thomasmarsh/received_events","type":"User","site_admin":false},"created_at":"2015-11-05T21:36:07Z","updated_at":"2015-11-05T21:36:07Z","body":"There is another case that I have found to be broken, in this case even with a unnamed union:\r\n\r\n```\r\n@0xc32fe40c798ee707;\r\n\r\nstruct A(T, U) {\r\n    union  {\r\n        t @0 :T;\r\n        u @1 :U;\r\n    }\r\n}\r\n```\r\n\r\nIn this case: \r\n\r\n```\r\nIn file included from a.capnp.c++:4:\r\n./a.capnp.h:31:5: error: declaration of 'T' shadows template parameter\r\n    T,\r\n    ^\r\n./a.capnp.h:23:20: note: template parameter is declared here\r\ntemplate <typename T = ::capnp::AnyPointer, typename U = ::capnp::AnyPointer>\r\n                   ^\r\n./a.capnp.h:32:5: error: declaration of 'U' shadows template parameter\r\n    U,\r\n    ^\r\n./a.capnp.h:23:54: note: template parameter is declared here\r\ntemplate <typename T = ::capnp::AnyPointer, typename U = ::capnp::AnyPointer>\r\n                                                     ^\r\n./a.capnp.h:41:105: error: template argument for template type parameter must be a type\r\n    static constexpr ::capnp::_::RawBrandedSchema const* brand = ::capnp::_::ChooseBrand<_capnpPrivate, T, U>::brand;\r\n                                                                                                        ^\r\n[snipped]\r\n```\r\n\r\nSo, I renamed the struct members to avoid the shadowing issue:\r\n\r\n```\r\n@0xc32fe40c798ee707;\r\n\r\nstruct A(T, U) {\r\n    union  {\r\n        x @0 :T;\r\n        y @1 :U;\r\n    }\r\n}\r\n```\r\n\r\nAnd then got different errors:\r\n\r\n```\r\nIn file included from a.capnp.c++:4:\r\n./a.capnp.h:181:3: error: expected '>'\r\n  KJ_IREQUIRE(which() == A<T, U>::X,\r\n  ^\r\n/usr/local/include/kj/common.h:204:9: note: expanded from macro 'KJ_IREQUIRE'\r\n    if (KJ_LIKELY(condition)); else ::kj::_::inlineRequireFailure( \\\r\n        ^\r\n/usr/local/include/kj/common.h:129:62: note: expanded from macro 'KJ_LIKELY'\r\n#define KJ_LIKELY(condition) __builtin_expect(condition, true)\r\n                                                             ^\r\nIn file included from a.capnp.c++:4:\r\n./a.capnp.h:181:31: error: 'U' does not refer to a value\r\n  KJ_IREQUIRE(which() == A<T, U>::X,\r\n                              ^\r\n/usr/local/include/kj/common.h:205:57: note: expanded from macro 'KJ_IREQUIRE'\r\n        __FILE__, __LINE__, #condition, #__VA_ARGS__, ##__VA_ARGS__)\r\n                                                        ^\r\n./a.capnp.h:179:32: note: declared here\r\ntemplate <typename T, typename U>\r\n                               ^\r\n[snipped]\r\n```\r\n\r\n"}}