Summary
Match guards are parsed and name resolved, but never type checked or compiled. An arm with a guard is taken whenever its pattern matches, and the guard never runs. Pattern support (#2082) lists guards as not done yet, but right now they compile without any error, so the program just behaves differently.
Reproducer
I tried this code:
#![feature(no_core)]
#![no_core]
fn never() -> bool {
false
}
fn main() -> i32 {
match 0 {
0 if never() => 1,
_ => 0,
}
}
Does the code make use of any (1.49) nightly feature ?
Godbolt link
No response
Actual behavior
The program exits with 1, and never is never called. A guard that isn't a bool, like 0 if 5 => ..., is accepted too.
Expected behavior
The guard runs, is false, and the program exits with 0.
GCC Version
36b5a15
Summary
Match guards are parsed and name resolved, but never type checked or compiled. An arm with a guard is taken whenever its pattern matches, and the guard never runs. Pattern support (#2082) lists guards as not done yet, but right now they compile without any error, so the program just behaves differently.
Reproducer
I tried this code:
Does the code make use of any (1.49) nightly feature ?
Godbolt link
No response
Actual behavior
The program exits with 1, and
neveris never called. A guard that isn't abool, like0 if 5 => ..., is accepted too.Expected behavior
The guard runs, is false, and the program exits with 0.
GCC Version
36b5a15