{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/22644","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/22644/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/22644/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/22644/events","html_url":"https://github.com/rust-lang/rust/issues/22644","id":58472761,"number":22644,"title":"Unable to parse expression `a as usize < b`","user":{"login":"defuz","id":276041,"avatar_url":"https://avatars.githubusercontent.com/u/276041?v=3","gravatar_id":"","url":"https://api.github.com/users/defuz","html_url":"https://github.com/defuz","followers_url":"https://api.github.com/users/defuz/followers","following_url":"https://api.github.com/users/defuz/following{/other_user}","gists_url":"https://api.github.com/users/defuz/gists{/gist_id}","starred_url":"https://api.github.com/users/defuz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/defuz/subscriptions","organizations_url":"https://api.github.com/users/defuz/orgs","repos_url":"https://api.github.com/users/defuz/repos","events_url":"https://api.github.com/users/defuz/events{/privacy}","received_events_url":"https://api.github.com/users/defuz/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rust-lang/rust/labels/A-diagnostics","name":"A-diagnostics","color":"d7e102"},{"url":"https://api.github.com/repos/rust-lang/rust/labels/A-parser","name":"A-parser","color":"d7e102"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":21,"created_at":"2015-02-21T20:03:03Z","updated_at":"2015-09-10T17:11:08Z","closed_at":null,"body":"It seems like the parser tries to read the type where it isn't:\r\n```rust\r\nfn main() {\r\n    let a : u32 = 0;\r\n    let b : usize = 0;\r\n\r\n    a as usize > b; // ok\r\n    a as usize < b; // error: expected one of `(`, `+`, `,`, `::`, `<`, or `>`, found `;`\r\n}\r\n```\r\n\r\nI think it's rather strange that the operator `>` works, but the operator `<` doesn't at the same place.\r\n\r\n`rustc 1.0.0-nightly (522d09dfe 2015-02-19) (built 2015-02-20)`"},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/139313024","html_url":"https://github.com/rust-lang/rust/issues/22644#issuecomment-139313024","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/22644","id":139313024,"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-09-10T17:11:08Z","updated_at":"2015-09-10T17:11:08Z","body":"@bstrie: The C#-style lookahead heuristic in my comment works for arity > 1; it just requires adding parentheses to disambiguate some rare cases (it never requires `::<>`). It would be a breaking change, though I would be surprised if there's much (any?) real-world code that would be broken.\r\n\r\nIt doesn't require exploiting [RFC 558](https://github.com/rust-lang/rfcs/pull/558) for the disambiguation. RFC 558 could theoretically be used to improve the heuristic (no need to look at the token following `>`), but only in the comma-free cases (arity 1 isn't sufficient, it could also be ambiguous if the single type argument is another generic type instantiation containing commas). But I don't think we should use it; adding an additional type argument to an existing generic call should always be valid.\r\n\r\nThe ugliness of `::<>` was why I started looking into that part of the syntax in the first place (I kinda forgot about that when I wrote RFC 558 a few days later). If we add support for Python-style chained comparisons in the future, we should probably only add monotonic comparisons (allow `a < b < c` and `a > b > c`, but not `a < b > c`) to avoid conflicts with generic syntax.\r\n\r\nThe main downside of the C#-style heuristic is that future additions to the type-level syntax would be breaking changes. So I think this should be postponed until type-level integer syntax is worked out."}}