Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upmatch expression falling through? #26251
Comments
This comment has been minimized.
This comment has been minimized.
|
If you increase the first range to With modified rangefn main() {
let x = 'a';
match x {
'a'...'c' if false => {
println!("one");
},
'a' => {
println!("two");
},
'a'...'b' => {
println!("three");
},
_ => panic!("what?")
}
}With commented-out following match armfn main() {
let x = 'a';
match x {
'a'...'b' if false => {
println!("one");
},
'a' => {
println!("two");
},
/*
'a'...'b' => {
println!("three");
},
*/
_ => panic!("what?")
}
} |
This comment has been minimized.
This comment has been minimized.
|
#18060 is similar but doesn't have guards. IMO, these should both be marked P-high, I-wrong. |
arielb1
added
I-wrong
P-high
labels
Jun 12, 2015
This comment has been minimized.
This comment has been minimized.
|
triage: I-nominated |
rust-highfive
added
I-nominated
and removed
P-high
labels
Jun 12, 2015
alexcrichton
added
the
T-compiler
label
Jun 12, 2015
This comment has been minimized.
This comment has been minimized.
|
cc @jakub- |
This comment has been minimized.
This comment has been minimized.
|
I agree this is totally bogus... seems like the chance of someone relying on this behavior is... low but not non-trivial? |
This comment has been minimized.
This comment has been minimized.
|
triage: P-high |
rust-highfive
added
P-high
and removed
I-nominated
labels
Jun 17, 2015
This comment has been minimized.
This comment has been minimized.
|
jrvidal ran across this in the wild so it can't be that low. |
This comment has been minimized.
This comment has been minimized.
|
FWIW, here is a simplified version of my use case, where I try to parse a number literal: loop {
match c {
// ...
'0'...'9' | 'a'...'f' if valid_digit(c, radix) => {/* parse digit */},
'e' | 'f' | 's' | 'd' | 'l' if is_decimal_literal() => {/* parse exponential marker */},
'0'...'9' | 'a'...'f' => {/* return error, bad digit */},
_ => break
}
} |
This comment has been minimized.
This comment has been minimized.
ghost
commented
Jun 20, 2015
|
The root problem is the same as #18060. I've gotta say that I'm convinced the trans bits for This, however, is extremely worrisome in that it can lead to really nasty bugs in user code. |
Stebalien
referenced this issue
Jun 21, 2015
Closed
Pattern match incorrectly optimized out (bad range info handling in LLVM?) #26468
eefriedman
added a commit
to eefriedman/rust
that referenced
this issue
Jul 15, 2015
eefriedman
referenced this issue
Jul 15, 2015
Closed
Rewrite the pattern matching code in trans. #27050
nikomatsakis
self-assigned this
Oct 1, 2015
This comment has been minimized.
This comment has been minimized.
|
triage: P-medium also mir, apparently |
rust-highfive
added
P-medium
and removed
P-high
labels
Nov 19, 2015
nrc
added
A-mir
and removed
P-medium
labels
Nov 19, 2015
This comment has been minimized.
This comment has been minimized.
|
I just compiled with the latest nightly and it seems to be working!
|
jrvidal commentedJun 12, 2015
I tried this code:
I expected to get
twobut I getthree. Is this the expected semantics?Meta
rustc --version --verbose:rustc 1.1.0-beta (cd7d89a 2015-05-16) (built 2015-05-16)
binary: rustc
commit-hash: cd7d89a
commit-date: 2015-05-16
build-date: 2015-05-16
host: x86_64-unknown-linux-gnu
release: 1.1.0-beta