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

issues with stmt arguments to macros #13679

Closed
comex opened this issue Apr 22, 2014 · 2 comments
Closed

issues with stmt arguments to macros #13679

comex opened this issue Apr 22, 2014 · 2 comments

Comments

@comex
Copy link
Contributor

comex commented Apr 22, 2014

I'm not exactly sure what it's supposed to do, but it seems wrong:

#![feature(macro_rules)]
macro_rules! some_stmts(
    ({ $($s:stmt)* }) => ($($s)*)
)

fn main() {
    some_stmts!({
        //let a = 5;
        type a = int;
    })
}

As is, we get:

stmts.rs:10:5: 10:6 error: local ambiguity: multiple parsing options: built-in NTs stmt ('s') or 1 other options.
stmts.rs:10     })

even though there is no way } could start a statement. With the let instead, it's

stmts.rs:8:18: 8:19 error: unexpected token: `;`
stmts.rs:8         let a = 5;

which doesn't seem to make sense either.

rustc 0.11-pre-nightly (d35804e 2014-04-18 00:01:22 -0700)

@lifthrasiir
Copy link
Contributor

Duplicate of #3232. The local ambiguity is caused by two states corresponding to { $( · $s:stmt )* } and { $( $s:stmt )* · } respectively, where the former is not really possible with the lookahead of } but the macro parser does not know that fact.

@alexcrichton
Copy link
Member

Closing as a dupe (as noted by @lifthrasiir)

arcnmx pushed a commit to arcnmx/rust that referenced this issue Dec 17, 2022
feat: allow unwrap block in let initializers

Possible fix for rust-lang#13679

### Points to help in review:

- I just added a parent case for let statements and it seems everything else was in place already, so turned out to be a small fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants