{"issue":{"pull_request":{"diff_url":null,"html_url":null,"patch_url":null},"state":"open","user":{"avatar_url":"https://secure.gravatar.com/avatar/eb640c52e5d534eb15d6a07bbc842db2?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"eb640c52e5d534eb15d6a07bbc842db2","url":"https://api.github.com/users/elly","login":"elly","id":218734},"milestone":null,"labels":[],"assignee":null,"updated_at":"2011-11-12T19:04:47Z","comments":2,"closed_at":null,"url":"https://api.github.com/repos/graydon/rust/issues/1170","body":"This rust program:\r\n[str-escape] ~/s/rust$ cat test.rs\r\nuse std;\r\n\r\nimport std::str;\r\n\r\nfn escape_char(c: char) -> str {\r\n    alt c {\r\n        '\"' { \"\\\"\" }\r\n        '\\\\' { \"\\\\\\\\\" }\r\n        '\\n' { \"\\\\n\" }\r\n        '\\t' { \"\\\\t\" }\r\n        '\\r' { \"\\\\r\" }\r\n        '\\x00' to '\\x1f' { #fmt[\"\\\\x%02x\", c as uint] }\r\n        v { str::from_char(c) }\r\n    }\r\n}\r\n\r\nfails to compile with this error:\r\ntest.rs:12:8: 12:24 error: unreachable pattern\r\ntest.rs:12         '\\x00' to '\\x1f' { #fmt[\"\\\\x%02x\", c as uint] }\r\n                   ^~~~~~~~~~~~~~~~\r\nerror: aborting due to previous errors\r\n\r\nInspection suggests that the logic in pattern_supersedes() in /src/comp/middle/check_alt.rs is wrong:\r\n    alt a.node {\r\n      pat_wild. | pat_bind(_) { ret true; }\r\n      pat_lit(la) {\r\n        alt b.node {\r\n          pat_lit(lb) { ret util::common::lit_eq(la, lb); }\r\n          pat_range(beginb, endb) {\r\n            ret util::common::lit_type_eq(la, beginb) &&\r\n                util::common::lit_in_range(la, beginb, endb);\r\n          }\r\n\r\n^ This returns true if a (a previous pattern) is contained in b (the current pattern) - i.e., this will match for alt x { 1 { ... } 1 to 10 { ... } }.","html_url":"https://github.com/graydon/rust/issues/1170","title":"Bogus \"unreachable pattern\" error with ranges","number":1170,"id":2206045,"created_at":"2011-11-11T03:37:21Z"},"action":"created","comment":{"user":{"avatar_url":"https://secure.gravatar.com/avatar/f6a35c85d26694e26bb92ea4d4262c77?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"f6a35c85d26694e26bb92ea4d4262c77","url":"https://api.github.com/users/marijnh","login":"marijnh","id":144427},"updated_at":"2011-11-12T19:04:47Z","url":"https://api.github.com/repos/graydon/rust/issues/comments/2718843","body":"I'm also in favour of changing this to only complain when the range is really unreachable.","id":2718843,"created_at":"2011-11-12T19:04:47Z"}}