gccrs icon indicating copy to clipboard operation
gccrs copied to clipboard

Emit error when range pattern is empty

Open braw-lee opened this issue 1 year ago • 5 comments

I couldn't find a cleaner way to get values of upper and lower bound. Tell me if there is a better way to get those values. @CohenArthur @P-E-P

braw-lee avatar Jan 15 '24 08:01 braw-lee

I'm unsure this should be done at this stage of the compiler, this surely is simpler after a bit of desugaring. Have you taken a look at rustc's way of doing this ? Is it doing it this early ?

P-E-P avatar Jan 15 '24 09:01 P-E-P

https://godbolt.org/z/sThP53WbG

pub fn main() {
    let _a = 1..=0;

    match 0 {
        1..=0 => {},
        _ => {}
    }

    let (1..=0, _b) = (1, 0);
}

It looks like the error only happens in match-like statements (the first line of the main function does not produce an error with rustc 1.49)

powerboat9 avatar Jan 16 '24 02:01 powerboat9

I wonder if that is the intended behaviour. I will ask in rustc if this is what they want or a missed case.

braw-lee avatar Jan 16 '24 03:01 braw-lee

I'm unsure this should be done at this stage of the compiler, this surely is simpler after a bit of desugaring. Have you taken a look at rustc's way of doing this ? Is it doing it this early ?

you are right, rustc actually handles this error in typed-hir stage.

braw-lee avatar Jan 16 '24 03:01 braw-lee

@braw-lee do you want some help on moving this to the typechecking phase?

CohenArthur avatar Jul 16 '24 11:07 CohenArthur