Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metavariable repetition in the matcher and the transcriber #1671

Open
pazmank opened this issue Nov 8, 2024 · 1 comment
Open

Metavariable repetition in the matcher and the transcriber #1671

pazmank opened this issue Nov 8, 2024 · 1 comment
Labels
A-macros Area: Macros

Comments

@pazmank
Copy link

pazmank commented Nov 8, 2024

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); 
}
@ehuss ehuss added the A-macros Area: Macros label Nov 8, 2024
@ehuss
Copy link
Contributor

ehuss commented Nov 8, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macros Area: Macros
Projects
None yet
Development

No branches or pull requests

2 participants