{"action":"closed","issue":{"url":"https://api.github.com/repos/stan-dev/stan/issues/2044","repository_url":"https://api.github.com/repos/stan-dev/stan","labels_url":"https://api.github.com/repos/stan-dev/stan/issues/2044/labels{/name}","comments_url":"https://api.github.com/repos/stan-dev/stan/issues/2044/comments","events_url":"https://api.github.com/repos/stan-dev/stan/issues/2044/events","html_url":"https://github.com/stan-dev/stan/issues/2044","id":174413837,"number":2044,"title":"Ternary operator generates C++ code that doesn't compile","user":{"login":"syclik","id":425751,"avatar_url":"https://avatars.githubusercontent.com/u/425751?v=3","gravatar_id":"","url":"https://api.github.com/users/syclik","html_url":"https://github.com/syclik","followers_url":"https://api.github.com/users/syclik/followers","following_url":"https://api.github.com/users/syclik/following{/other_user}","gists_url":"https://api.github.com/users/syclik/gists{/gist_id}","starred_url":"https://api.github.com/users/syclik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/syclik/subscriptions","organizations_url":"https://api.github.com/users/syclik/orgs","repos_url":"https://api.github.com/users/syclik/repos","events_url":"https://api.github.com/users/syclik/events{/privacy}","received_events_url":"https://api.github.com/users/syclik/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":{"login":"mitzimorris","id":5466612,"avatar_url":"https://avatars.githubusercontent.com/u/5466612?v=3","gravatar_id":"","url":"https://api.github.com/users/mitzimorris","html_url":"https://github.com/mitzimorris","followers_url":"https://api.github.com/users/mitzimorris/followers","following_url":"https://api.github.com/users/mitzimorris/following{/other_user}","gists_url":"https://api.github.com/users/mitzimorris/gists{/gist_id}","starred_url":"https://api.github.com/users/mitzimorris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitzimorris/subscriptions","organizations_url":"https://api.github.com/users/mitzimorris/orgs","repos_url":"https://api.github.com/users/mitzimorris/repos","events_url":"https://api.github.com/users/mitzimorris/events{/privacy}","received_events_url":"https://api.github.com/users/mitzimorris/received_events","type":"User","site_admin":false},"assignees":[{"login":"mitzimorris","id":5466612,"avatar_url":"https://avatars.githubusercontent.com/u/5466612?v=3","gravatar_id":"","url":"https://api.github.com/users/mitzimorris","html_url":"https://github.com/mitzimorris","followers_url":"https://api.github.com/users/mitzimorris/followers","following_url":"https://api.github.com/users/mitzimorris/following{/other_user}","gists_url":"https://api.github.com/users/mitzimorris/gists{/gist_id}","starred_url":"https://api.github.com/users/mitzimorris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitzimorris/subscriptions","organizations_url":"https://api.github.com/users/mitzimorris/orgs","repos_url":"https://api.github.com/users/mitzimorris/repos","events_url":"https://api.github.com/users/mitzimorris/events{/privacy}","received_events_url":"https://api.github.com/users/mitzimorris/received_events","type":"User","site_admin":false}],"milestone":null,"comments":13,"created_at":"2016-09-01T01:04:43Z","updated_at":"2016-09-02T03:42:24Z","closed_at":"2016-09-02T03:42:24Z","body":"#### Summary:\r\nThe code generator is generating code that doesn't compile. The issue is with the ternary operator.\r\n\r\n#### Description:\r\nThe C++ that's generated is incorrect. Below is a minimal example.\r\n\r\n#### Reproducible Steps:\r\nThis Stan program will translate to C++, but not compile.\r\n\r\n```stan\r\ntransformed parameters {\r\n  real x;\r\n  x = (0 ? x : 0);\r\n}\r\nmodel {\r\n}\r\n```\r\n\r\nThere's an explicit cast to `double`, which is causing the failure.\r\n\r\n#### Current Output:\r\nCompiler error that looks like (trimmed):\r\n```\r\nIn file included from <built-in>:336:\r\nIn file included from <command line>:8:\r\n./foo.hpp:129:40: error: cannot convert 'stan::math::var' to 'double' without a conversion operator\r\n            stan::math::assign(x, (0 ? double(x) : double(0) ));\r\n                                       ^~~~~~~~\r\n```\r\n\r\n#### Expected Output:\r\nIt should compile fine.\r\n\r\nPerhaps instead of generating:\r\n```\r\n            stan::math::assign(x, (0 ? double(x) : double(0) ));\r\n```\r\n\r\nwe can generate:\r\n```\r\n            stan::math::assign(x, (0 ? x : 0 ));\r\n```\r\n?\r\n\r\n(I can see how that might be a problem.)\r\n\r\n#### Current Version:\r\nv2.11.0\r\n"}}
{"actor":{"display_login":"syclik"}}