reference icon indicating copy to clipboard operation
reference copied to clipboard

Metavariable repetition in the matcher and the transcriber

Open pazmank opened this issue 1 year ago • 1 comments

According to chapter 3.1., a metavariable must appear in exactly the same number, kind, and nesting order of repetitions in the transcriber as it did in the matcher. Based on this, I expected the following code (playground) not to compile, but it does compile without error.

macro_rules! repeat1 {
    ($($x:expr),+) => {
        $(let _ = $x;)*
    };
}
    
macro_rules! repeat2 {
    ($($x:expr),+) => {
        $(let _ = $x;)?
    };
}

macro_rules! repeat3 {
    ($($x:expr),*) => {
        $(let _ = $x;)?
    };
}
    
fn main() {
    repeat1!(1,2,3); 
    repeat2!(1,2,3); 
    repeat3!(1,2,3); 
}

pazmank avatar Nov 08 '24 08:11 pazmank

Yea, that section doesn't look correct to me (even back to 1.0, mixing seems to be allowed to some degree).

ehuss avatar Nov 08 '24 13:11 ehuss