{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/34704","repository_url":"https://api.github.com/repos/rust-lang/rust","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/34704/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/34704/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/34704/events","html_url":"https://github.com/rust-lang/rust/issues/34704","id":164353445,"number":34704,"title":"this is funny :)","user":{"login":"icanrealizeum","id":20287290,"avatar_url":"https://avatars.githubusercontent.com/u/20287290?v=3","gravatar_id":"","url":"https://api.github.com/users/icanrealizeum","html_url":"https://github.com/icanrealizeum","followers_url":"https://api.github.com/users/icanrealizeum/followers","following_url":"https://api.github.com/users/icanrealizeum/following{/other_user}","gists_url":"https://api.github.com/users/icanrealizeum/gists{/gist_id}","starred_url":"https://api.github.com/users/icanrealizeum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/icanrealizeum/subscriptions","organizations_url":"https://api.github.com/users/icanrealizeum/orgs","repos_url":"https://api.github.com/users/icanrealizeum/repos","events_url":"https://api.github.com/users/icanrealizeum/events{/privacy}","received_events_url":"https://api.github.com/users/icanrealizeum/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-07-07T16:33:44Z","updated_at":"2016-07-07T16:46:14Z","closed_at":"2016-07-07T16:46:14Z","body":"The funny part is that in the same place we get these two errors:\r\n`expected i32, found ()`\r\n`expected (), found i32`\r\nI get why it happens, I just thought it's a funny quirk :D\r\n\r\n```rust\r\nfn main() {\r\n    let x = 5;\r\n\r\n    let y: i32 = if x == 5 {\r\n        10\r\n    };\r\n    println!(\"{:?}\",y);\r\n}\r\n```\r\n\r\n```\r\nerror: if may be missing an else clause [--explain E0308]\r\n --> <anon>:4:18\r\n  |>\r\n4 |>     let y: i32 = if x == 5 {\r\n  |>                  ^ expected (), found i32\r\nnote: expected type `()`\r\nnote:    found type `i32`\r\n\r\nerror: aborting due to previous error\r\nCompilation failed.\r\n```\r\n\r\n`expected (), found i32`\r\n\r\n```rust\r\nfn main() {\r\n    let x = 5;\r\n\r\n    let y: i32 = if x == 5 {\r\n        10;\r\n    };\r\n    println!(\"{:?}\",y);\r\n}\r\n```\r\n\r\n\r\n**EDIT:** grrrr, accidentally pressed Ctrl+Enter and I wasn't done editing!!!\r\n\r\n```\r\nerror: mismatched types [--explain E0308]\r\n --> <anon>:4:18\r\n  |>\r\n4 |>     let y: i32 = if x == 5 {\r\n  |>                  ^ expected i32, found ()\r\nnote: expected type `i32`\r\nnote:    found type `()`\r\n\r\nerror: aborting due to previous error\r\n```\r\n\r\n`expected i32, found ()`\r\n\r\n\r\nsource: https://doc.rust-lang.org/book/if.html"},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/231137714","html_url":"https://github.com/rust-lang/rust/issues/34704#issuecomment-231137714","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/34704","id":231137714,"user":{"login":"arielb1","id":1830974,"avatar_url":"https://avatars.githubusercontent.com/u/1830974?v=3","gravatar_id":"","url":"https://api.github.com/users/arielb1","html_url":"https://github.com/arielb1","followers_url":"https://api.github.com/users/arielb1/followers","following_url":"https://api.github.com/users/arielb1/following{/other_user}","gists_url":"https://api.github.com/users/arielb1/gists{/gist_id}","starred_url":"https://api.github.com/users/arielb1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arielb1/subscriptions","organizations_url":"https://api.github.com/users/arielb1/orgs","repos_url":"https://api.github.com/users/arielb1/repos","events_url":"https://api.github.com/users/arielb1/events{/privacy}","received_events_url":"https://api.github.com/users/arielb1/received_events","type":"User","site_admin":false},"created_at":"2016-07-07T16:46:14Z","updated_at":"2016-07-07T16:46:14Z","body":"Yeah. In one case the error is caused by the type annotation, and in the other the error is caused by an if expression without an else. Type errors are and will continue to be reported by the first place that finds them."}}
{"actor":{"display_login":"arielb1"}}