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

${count(t,)} is interpreted as ${count(t, 0)} #111904

Closed
lowr opened this issue May 24, 2023 · 0 comments · Fixed by #111908
Closed

${count(t,)} is interpreted as ${count(t, 0)} #111904

lowr opened this issue May 24, 2023 · 0 comments · Fixed by #111908
Labels
C-bug Category: This is a bug. F-macro_metavar_expr `#![feature(macro_metavar_expr)]` requires-nightly This issue requires a nightly compiler in some way.

Comments

@lowr
Copy link
Contributor

lowr commented May 24, 2023

I tried this code:

#![feature(macro_metavar_expr)]

macro_rules! foo {
    ( $( $($t:ident),* );* ) => { ${count(t,)} }
}

fn test() {
    foo!(a, a; b, b);
}

I expected to see this happen:

Either:

  • The macro definition is rejected, leading to a compile error.
  • ${count(t,)} is interpreted as ${count(t)}, the macro call is expanded to 4.

Instead, this happened:
Compiled successfully, ${count(t,)} is interpreted as ${count(t, 0)}, the macro call is expanded to 2.

This form of ${count()} metavar expression is not specified in RFC 3086, so this is more of an ask for clarification than a bug report.

Meta

rustc --version --verbose:

1.71.0-nightly (2023-05-23 5ea3f0ae08c07472239a)

cc #83527
@rustbot label requires-nightly F-macro-metavar-expr

@lowr lowr added the C-bug Category: This is a bug. label May 24, 2023
@rustbot rustbot added F-macro_metavar_expr `#![feature(macro_metavar_expr)]` requires-nightly This issue requires a nightly compiler in some way. labels May 24, 2023
@bors bors closed this as completed in b9177c0 Aug 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. F-macro_metavar_expr `#![feature(macro_metavar_expr)]` requires-nightly This issue requires a nightly compiler in some way.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants