{"action":"closed","issue":{"url":"https://api.github.com/repos/andreasfertig/cppinsights/issues/46","repository_url":"https://api.github.com/repos/andreasfertig/cppinsights","labels_url":"https://api.github.com/repos/andreasfertig/cppinsights/issues/46/labels{/name}","comments_url":"https://api.github.com/repos/andreasfertig/cppinsights/issues/46/comments","events_url":"https://api.github.com/repos/andreasfertig/cppinsights/issues/46/events","html_url":"https://github.com/andreasfertig/cppinsights/issues/46","id":341330551,"node_id":"MDU6SXNzdWUzNDEzMzA1NTE=","number":46,"title":"Expansion of global lambda expressions is broken","user":{"login":"neobrain","id":4840017,"node_id":"MDQ6VXNlcjQ4NDAwMTc=","avatar_url":"https://avatars0.githubusercontent.com/u/4840017?v=4","gravatar_id":"","url":"https://api.github.com/users/neobrain","html_url":"https://github.com/neobrain","followers_url":"https://api.github.com/users/neobrain/followers","following_url":"https://api.github.com/users/neobrain/following{/other_user}","gists_url":"https://api.github.com/users/neobrain/gists{/gist_id}","starred_url":"https://api.github.com/users/neobrain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neobrain/subscriptions","organizations_url":"https://api.github.com/users/neobrain/orgs","repos_url":"https://api.github.com/users/neobrain/repos","events_url":"https://api.github.com/users/neobrain/events{/privacy}","received_events_url":"https://api.github.com/users/neobrain/received_events","type":"User","site_admin":false},"labels":[{"id":917673914,"node_id":"MDU6TGFiZWw5MTc2NzM5MTQ=","url":"https://api.github.com/repos/andreasfertig/cppinsights/labels/bug","name":"bug","color":"d73a4a","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-07-15T15:52:41Z","updated_at":"2018-07-15T19:16:32Z","closed_at":"2018-07-15T19:16:32Z","author_association":"NONE","body":"Lambda expressions at global scope generate unintelligible output. C++ Insights is supposed to replace them with equivalent, explicit class definitions, but this only seems to work properly for lambda expressions defined inside a function.\r\n\r\nThe following table illustrates the output for a locally defined lambda (fine) vs. two instances of global lambdas (broken).\r\n\r\n<table>\r\n<tr>\r\n<th>\r\nInput\r\n</th>\r\n<th>\r\nC++ Insights\r\n</th>\r\n</tr>\r\n<tr>\r\n<td  valign=\"top\">\r\n<pre lang=\"cpp\">\r\nint main() {\r\n    auto x = [a=5](int b) {\r\n        return b*a;\r\n    };\r\n}</pre>\r\n</td>\r\n<td  valign=\"top\">\r\n<pre lang=\"cpp\">\r\nint main() {\r\n  class __lambda_10_14 {\r\n    public: inline /*constexpr */ int operator()(int b) const {\r\n      return b * a;\r\n    }\r\n\r\n&nbsp;&nbsp;&nbsp;&nbsp;private:\r\n&nbsp;&nbsp;&nbsp;&nbsp;int a;\r\n    \r\n&nbsp;&nbsp;&nbsp;&nbsp;public:\r\n&nbsp;&nbsp;&nbsp;&nbsp;__lambda_10_14(int _a)\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: a{_a}\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{}\r\n&nbsp;&nbsp;};\r\n  \r\n&nbsp;__lambda_10_14 x = __lambda_10_14{5};\r\n}\r\n</pre>\r\n</td>\r\n</tr>\r\n<tr>\r\n<td  valign=\"top\">\r\n<pre lang=\"cpp\">\r\nauto x = []() {\r\n    return 5;\r\n};\r\n</pre>\r\n</td>\r\n<td  valign=\"top\">\r\n<pre lang=\"cpp\">\r\n__lambda_1_10 x = /* public: inline ~() noexcept; */\r\nstatic inline int __invoke();\r\n         ;\r\n</pre>\r\n</td>\r\n</tr>\r\n</tr>\r\n<tr>\r\n<td  valign=\"top\">\r\n<pre lang=\"cpp\">\r\nauto x2 = [a=5](int b) {\r\n    return b*a;\r\n};\r\n</pre>\r\n</td>\r\n<td  valign=\"top\">\r\n<pre lang=\"cpp\">\r\n\r\n__lambda_5_11 x2 = /* public: inline ~() noexcept; */\r\n[inta=5](int binline constexpr int operator()(int b) const\r\n                     {\r\n                       return b * a;\r\n                     }\r\n                     ;\r\n</pre>\r\n</td>\r\n</tr>\r\n</tr>\r\n</table>\r\n"}}
{"actor":{"display_login":"andreasfertig"}}