{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/28785","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/28785/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/28785/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/28785/events","html_url":"https://github.com/rust-lang/rust/issues/28785","id":109234711,"number":28785,"title":"Range expressions: discrepancies between rustc and parser-lalr","user":{"login":"rprichard","id":1572855,"avatar_url":"https://avatars.githubusercontent.com/u/1572855?v=3","gravatar_id":"","url":"https://api.github.com/users/rprichard","html_url":"https://github.com/rprichard","followers_url":"https://api.github.com/users/rprichard/followers","following_url":"https://api.github.com/users/rprichard/following{/other_user}","gists_url":"https://api.github.com/users/rprichard/gists{/gist_id}","starred_url":"https://api.github.com/users/rprichard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rprichard/subscriptions","organizations_url":"https://api.github.com/users/rprichard/orgs","repos_url":"https://api.github.com/users/rprichard/repos","events_url":"https://api.github.com/users/rprichard/events{/privacy}","received_events_url":"https://api.github.com/users/rprichard/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rust-lang/rust/labels/A-grammar","name":"A-grammar","color":"d7e102"},{"url":"https://api.github.com/repos/rust-lang/rust/labels/P-medium","name":"P-medium","color":"eb6420"},{"url":"https://api.github.com/repos/rust-lang/rust/labels/T-lang","name":"T-lang","color":"bfd4f2"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-10-01T05:53:05Z","updated_at":"2015-11-04T14:10:01Z","closed_at":null,"body":"I'd guess that the last test case here is a `rustc` bug, but I don't know about the others.\r\n\r\n```rust\r\nfn match_rangefull() {\r\n    match .. { _ => () } // rustc compiles it, parser-lalr rejects\r\n}\r\nfn field_of_range() {\r\n    123.. .start; // rustc rejects, parser-lalr accepts\r\n}\r\nfn eq_rangefull() {\r\n    .. == ..; // rustc rejects, parser-lalr accepts\r\n}\r\nfn return_rangeto() -> std::ops::RangeTo<i32> {\r\n    return ..5; // rustc compiles it, parser-lalr parses it as (return)..5\r\n}\r\nfn assign_range() {\r\n    let x;\r\n    x = 4..5; // rustc compiles it, parser-lalr parses it as (x = 4)..5\r\n}\r\nfn nonblock_expr_range() {\r\n    // rustc compiles this, and I don't think it should.  I think parser-lalr\r\n    // gets it right.\r\n    //\r\n    //    rustc parses it like:       let _one = (1..).start;\r\n    //    parser-lalr parses it like: let _one = {1; ..}.start;\r\n    //\r\n    let _one = { {1} .. }.start;\r\n}\r\nfn main() {}\r\n```\r\nAlso see https://github.com/rust-lang/rust/issues/25119.\r\n"},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/153730200","html_url":"https://github.com/rust-lang/rust/issues/28785#issuecomment-153730200","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/28785","id":153730200,"user":{"login":"dgrunwald","id":243140,"avatar_url":"https://avatars.githubusercontent.com/u/243140?v=3","gravatar_id":"","url":"https://api.github.com/users/dgrunwald","html_url":"https://github.com/dgrunwald","followers_url":"https://api.github.com/users/dgrunwald/followers","following_url":"https://api.github.com/users/dgrunwald/following{/other_user}","gists_url":"https://api.github.com/users/dgrunwald/gists{/gist_id}","starred_url":"https://api.github.com/users/dgrunwald/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgrunwald/subscriptions","organizations_url":"https://api.github.com/users/dgrunwald/orgs","repos_url":"https://api.github.com/users/dgrunwald/repos","events_url":"https://api.github.com/users/dgrunwald/events{/privacy}","received_events_url":"https://api.github.com/users/dgrunwald/received_events","type":"User","site_admin":false},"created_at":"2015-11-04T14:10:01Z","updated_at":"2015-11-04T14:10:01Z","body":"Can you explain why you think that `{ {1} .. }.start` should parse as `{1; ..}.start`? I'm not familiar with the details of Rust's semicolon insertion.\r\n\r\nI would expect `{}` within an expression to work pretty much wherever `()` does (except in if conditions / match expressions or similar, where `{}` starts the control flow block), and `((1)..).start` is definitely valid syntax.\r\n\r\nOn all other examples, I'd say the rustc behavior is correct. The decision in #21374 was: `..` is non-associative has the same precedence as the assignment operator. The unary forms of `..` are only valid at the same precedence level as the binary form.\r\n\r\nComparing ranges needs parentheses: the attempt to give `..` a higher precedence than the comparison operators in #20811 was not adopted because it caused new ambiguities between unary and binary `&&`, e.g. in `r == 1.. && condition`.\r\n\r\nAdmittedly, having `..` at the same precedence level as assignment is somewhat weird, as the operators on that level have different associativity (assignment is right-associative; `..` is non-associative). It would be better to put `..` on its own level directly above the assignment operator and placement-new-arrow."}}